<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Eli Bendersky's website - Math</title><link href="https://eli.thegreenplace.net/" rel="alternate"></link><link href="https://eli.thegreenplace.net/feeds/math.atom.xml" rel="self"></link><id>https://eli.thegreenplace.net/</id><updated>2026-05-28T02:29:23-07:00</updated><entry><title>Notes on Fourier series</title><link href="https://eli.thegreenplace.net/2026/notes-on-fourier-series/" rel="alternate"></link><published>2026-05-27T19:30:00-07:00</published><updated>2026-05-28T02:29:23-07:00</updated><author><name>Eli Bendersky</name></author><id>tag:eli.thegreenplace.net,2026-05-27:/2026/notes-on-fourier-series/</id><summary type="html">&lt;link rel="stylesheet" href="https://eli.thegreenplace.net/demos/fourier/fourier-plot.css"&gt;&lt;p&gt;The trigonometric Fourier series is a beautiful mathematical theory that
shows how to decompose a periodic function into an infinite sum of
sinusoids. These are my notes on the subject, with some examples and the
connection to linear algebra in Hilbert space.&lt;/p&gt;
&lt;div class="section" id="coefficients-of-fourier-series"&gt;
&lt;h2&gt;Coefficients of Fourier series&lt;/h2&gt;
&lt;p&gt;Let’s assume that …&lt;/p&gt;&lt;/div&gt;</summary><content type="html">&lt;link rel="stylesheet" href="https://eli.thegreenplace.net/demos/fourier/fourier-plot.css"&gt;&lt;p&gt;The trigonometric Fourier series is a beautiful mathematical theory that
shows how to decompose a periodic function into an infinite sum of
sinusoids. These are my notes on the subject, with some examples and the
connection to linear algebra in Hilbert space.&lt;/p&gt;
&lt;div class="section" id="coefficients-of-fourier-series"&gt;
&lt;h2&gt;Coefficients of Fourier series&lt;/h2&gt;
&lt;p&gt;Let’s assume that &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; is a &lt;em&gt;well-behaved&lt;/em&gt; &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/8dde33545500de38fae974b4b18036def142e9e3.svg" style="height: 12px;" type="image/svg+xml"&gt;2L&lt;/object&gt;-periodic &lt;a class="footnote-reference" href="#footnote-1" id="footnote-reference-1"&gt;[1]&lt;/a&gt;
function and that we can find coefficients &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/278ab95d3a54aae8eaa25c34af66d93a19b5e75f.svg" style="height: 11px;" type="image/svg+xml"&gt;a_n&lt;/object&gt; and &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/54d608cbef1529c3089b9281aa6dcb16a2e65f1f.svg" style="height: 15px;" type="image/svg+xml"&gt;b_n&lt;/object&gt;
such that:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/628f7339c7c4d164a982b8da9b48b213692dd5b3.svg" style="height: 49px;" type="image/svg+xml"&gt;\[f(x)=\sum_{n=0}^{\infty}\left(a_n cos\frac{n\pi x}{L}+b_n sin\frac{n\pi x}{L}\right)\]&lt;/object&gt;
&lt;p&gt;Then we say that the &lt;em&gt;Fourier series&lt;/em&gt; on the right-hand side converges
to &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt;. We’ll talk more about the assumptions mentioned above
and convergence in the next section.&lt;/p&gt;
&lt;p&gt;Note that when &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/bfbd617aa9bc9d5a8b0b006de9d1d45d8e688c8d.svg" style="height: 12px;" type="image/svg+xml"&gt;n=0&lt;/object&gt;, the sum becomes just &lt;img alt="a_0" class="valign-m3" src="https://eli.thegreenplace.net/images/math/4a5997da73aadd118038761e69d01e24586bf958.png" style="height: 11px;" /&gt;; therefore
it’s customary to write the series starting with &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/01ea4b6bd17ee603696dd6e63b08b3ba75b78dce.svg" style="height: 12px;" type="image/svg+xml"&gt;n=1&lt;/object&gt;, with a
separate constant component (which is the function's average over
one period). To make computations nicer, this constant is typically
called &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/770db1916542e8d8eb0e85082134672f66f2544a.svg" style="height: 19px;" type="image/svg+xml"&gt;a_0 / 2&lt;/object&gt;, so:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/af4acda237be7c5348b05201f8f6f6c6b75e30b9.svg" style="height: 49px;" type="image/svg+xml"&gt;\[f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}\left(a_n cos\frac{n\pi x}{L}+b_n sin\frac{n\pi x}{L}\right)\]&lt;/object&gt;
&lt;p&gt;Our goal is to find the coefficients &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/278ab95d3a54aae8eaa25c34af66d93a19b5e75f.svg" style="height: 11px;" type="image/svg+xml"&gt;a_n&lt;/object&gt; and &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/54d608cbef1529c3089b9281aa6dcb16a2e65f1f.svg" style="height: 15px;" type="image/svg+xml"&gt;b_n&lt;/object&gt; that
satisfy this equation. We’ll do this in three steps.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Integrate both sides of the equation between &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/c20a39eb3af4897aa4dea2bd9a1ba1a16fa16352.svg" style="height: 12px;" type="image/svg+xml"&gt;-L&lt;/object&gt; and
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/d160e0986aca4714714a16f29ec605af90be704d.svg" style="height: 12px;" type="image/svg+xml"&gt;L&lt;/object&gt;  &lt;a class="footnote-reference" href="#footnote-2" id="footnote-reference-2"&gt;[2]&lt;/a&gt;.&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/d846619340aeef0b7af2015c25413e6d9947e659.svg" style="height: 50px;" type="image/svg+xml"&gt;\[\int_{-L}^{L}f(x)dx=\int_{-L}^{L}\frac{a_0}{2}dx+\sum_{n=1}^{\infty}\bigg (\int_{-L}^{L}a_n cos\frac{n\pi x}{L}dx+\int_{-L}^{L}b_n sin\frac{n\pi x}{L}dx\bigg )\]&lt;/object&gt;
&lt;p&gt;Per Appendix A, all integrals within the sum are zero, so we’re left
with:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/63c90dd5684c96b1f14a49bfb6c7a6dd7e8fcbd3.svg" style="height: 47px;" type="image/svg+xml"&gt;\[\int_{-L}^{L}f(x)dx=\int_{-L}^{L}\frac{a_0}{2}dx=\bigg[\frac{x\cdot a_0}{2}\bigg]_{-L}^{L}=a_0\cdot L\]&lt;/object&gt;
&lt;p&gt;And thus we find &lt;img alt="a_0" class="valign-m3" src="https://eli.thegreenplace.net/images/math/4a5997da73aadd118038761e69d01e24586bf958.png" style="height: 11px;" /&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/455f8d7d3f17720a2f2c577004b50b71999e5ac8.svg" style="height: 44px;" type="image/svg+xml"&gt;\[a_0=\frac{1}{L}\int_{-L}^{L}f(x)dx\]&lt;/object&gt;
&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Multiply both sides by &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/32329deb8300f4dcae316379bcc624efe02d10d9.svg" style="height: 19px;" type="image/svg+xml"&gt;cos\frac{m\pi x}{L}&lt;/object&gt;
(&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/6b0d31c0d563223024da45691584643ac78c96e8.svg" style="height: 8px;" type="image/svg+xml"&gt;m&lt;/object&gt; is a positive integer constant) and integrate between
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/c20a39eb3af4897aa4dea2bd9a1ba1a16fa16352.svg" style="height: 12px;" type="image/svg+xml"&gt;-L&lt;/object&gt; and &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/d160e0986aca4714714a16f29ec605af90be704d.svg" style="height: 12px;" type="image/svg+xml"&gt;L&lt;/object&gt;.&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/1584e8cb2c704d84ba6e4d6fab63a999698b1e13.svg" style="height: 102px;" type="image/svg+xml"&gt;\[\begin{aligned}
    \int_{-L}^{L}f(x)cos\frac{m\pi x}{L}dx&amp;amp;=\int_{-L}^{L}\frac{a_0}{2}cos\frac{m\pi x}{L}dx\\
    &amp;amp;+\sum_{n=1}^{\infty}\bigg (\int_{-L}^{L}a_n cos\frac{n\pi x}{L}cos\frac{m\pi x}{L}dx+\int_{-L}^{L}b_n sin\frac{n\pi x}{L}cos\frac{m\pi x}{L}dx\bigg )
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Looking at the right-hand side, the first integral is zero per Appendix
A, and the last integral is zero per Appendix B. We’re left with:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/0bc1f95f24482ce2b1292415f2d9759ed6ac9b3c.svg" style="height: 49px;" type="image/svg+xml"&gt;\[\int_{-L}^{L}f(x)cos\frac{m\pi x}{L}dx=\sum_{n=1}^{\infty}\int_{-L}^{L}a_n cos\frac{n\pi x}{L}cos\frac{m\pi x}{L}dx\]&lt;/object&gt;
&lt;p&gt;Per Appendix B, the integral on the right is zero for all
&lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/3ae4a06555822644174f9ff9419084466b3f7aa4.svg" style="height: 17px;" type="image/svg+xml"&gt;n\neq m&lt;/object&gt;, and &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/d160e0986aca4714714a16f29ec605af90be704d.svg" style="height: 12px;" type="image/svg+xml"&gt;L&lt;/object&gt; for &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/193bdae8b42385001cd707bc207b1d95bd6dc2b2.svg" style="height: 8px;" type="image/svg+xml"&gt;n=m&lt;/object&gt;. Therefore, we can write:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/67f393e48f6792c8ed7fb23b3388496540507fab.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\int_{-L}^{L}f(x)cos\frac{m\pi x}{L}dx=a_m\cdot L\]&lt;/object&gt;
&lt;p&gt;Recall that &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/6b0d31c0d563223024da45691584643ac78c96e8.svg" style="height: 8px;" type="image/svg+xml"&gt;m&lt;/object&gt; is an arbitrary integer, just like &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt;; for
consistency, we’ll replace &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/6b0d31c0d563223024da45691584643ac78c96e8.svg" style="height: 8px;" type="image/svg+xml"&gt;m&lt;/object&gt; by &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt; and isolate
&lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/278ab95d3a54aae8eaa25c34af66d93a19b5e75f.svg" style="height: 11px;" type="image/svg+xml"&gt;a_n&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/f2e9e0215460f6630905ed01ddfbec5116473b88.svg" style="height: 44px;" type="image/svg+xml"&gt;\[a_n=\frac{1}{L}\int_{-L}^{L}f(x)cos\frac{n\pi x}{L}dx\]&lt;/object&gt;
&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Hopefully it’s clear where this is going now; multiply both
sides by &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/8e9b9f212b20b5a5c03a472debd56362a9c7a608.svg" style="height: 19px;" type="image/svg+xml"&gt;sin\frac{m\pi x}{L}&lt;/object&gt; and integrate between &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/c20a39eb3af4897aa4dea2bd9a1ba1a16fa16352.svg" style="height: 12px;" type="image/svg+xml"&gt;-L&lt;/object&gt;
and &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/d160e0986aca4714714a16f29ec605af90be704d.svg" style="height: 12px;" type="image/svg+xml"&gt;L&lt;/object&gt;. Using a very similar reasoning to step 2, we’ll end up
with:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/418eef7e6ac0ffd84fc9d87246f1329d17cb6d4c.svg" style="height: 44px;" type="image/svg+xml"&gt;\[b_n=\frac{1}{L}\int_{-L}^{L}f(x)sin\frac{n\pi x}{L}dx\]&lt;/object&gt;
&lt;p&gt;We’ve just found a way to calculate all the coefficients of our Fourier
series for &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/af4acda237be7c5348b05201f8f6f6c6b75e30b9.svg" style="height: 49px;" type="image/svg+xml"&gt;\[f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}\left(a_n cos\frac{n\pi x}{L}+b_n sin\frac{n\pi x}{L}\right)\]&lt;/object&gt;
&lt;p&gt;Where:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/425afbd1b4528c1480d81e007c564dc8fdaf02b8.svg" style="height: 148px;" type="image/svg+xml"&gt;\[\begin{aligned}
    a_0&amp;amp;=\frac{1}{L}\int_{-L}^{L}f(x)dx\\
    a_n&amp;amp;=\frac{1}{L}\int_{-L}^{L}f(x)cos\frac{n\pi x}{L}dx\\
    b_n&amp;amp;=\frac{1}{L}\int_{-L}^{L}f(x)sin\frac{n\pi x}{L}dx
\end{aligned}\]&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="conditions-on-f-and-convergence-of-fourier-series"&gt;
&lt;h2&gt;Conditions on &lt;em&gt;f&lt;/em&gt; and convergence of Fourier series&lt;/h2&gt;
&lt;p&gt;The previous section discusses Fourier series for a function
&lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; that is &lt;em&gt;well-behaved&lt;/em&gt; - but what does that mean? The full
answer would lead us deep into analysis, which I’d like to avoid here.
So I’ll keep it brief.&lt;/p&gt;
&lt;p&gt;We typically assume that &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; is &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Square-integrable_function"&gt;square
integrable&lt;/a&gt;,
which is denoted as &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/f1aae083af2c79348dd78712847ebd55537fa6e6.svg" style="height: 15px;" type="image/svg+xml"&gt;L^2&lt;/object&gt;. Moreover, we assume that the function
is &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Piecewise_function"&gt;piecewise
smooth&lt;/a&gt;: each
segment of the function has continuous derivatives. A very simple
example of a piecewise smooth function is &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/b984af7493f86f1c75ccaa101e16d173cf00622f.svg" style="height: 19px;" type="image/svg+xml"&gt;f(x)=|x|&lt;/object&gt;. Another is
the triangular wave function used in the example below.&lt;/p&gt;
&lt;p&gt;These conditions hold for pretty much any reasonable function we want to
approximate using Fourier series, so they aren’t a serious burden.&lt;/p&gt;
&lt;p&gt;For a function &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; that satisfies these conditions, it’s
guaranteed to have a Fourier series that &lt;em&gt;pointwise converges&lt;/em&gt; to it.
This means that at every continuous point of &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt;, the Fourier
series converges to it exactly; at every jump point, the Fourier series
converges to the mid-point of the jump.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="cosine-and-sine-series"&gt;
&lt;h2&gt;Cosine and Sine series&lt;/h2&gt;
&lt;p&gt;Sometimes, additional properties of the function &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; can help
us simplify the Fourier series for it. If &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/945519cc8666a0a6bfd3a390a10cd7fb2facc3bc.svg" style="height: 19px;" type="image/svg+xml"&gt;f_e(x)&lt;/object&gt; is an &lt;a class="reference external" href="https://eli.thegreenplace.net/2025/notes-on-even-and-odd-functions/"&gt;even
function&lt;/a&gt;,
then we know that:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/86ec9b5d04ec9bfba3910311d88ecf40e4379983.svg" style="height: 44px;" type="image/svg+xml"&gt;\[b_n=\frac{1}{L}\int_{-L}^{L}f(x)sin\frac{n\pi x}{L}dx=0\]&lt;/object&gt;
&lt;p&gt;Because the function inside the integral is odd, and integrating an
odd function over a symmetric interval results in 0.&lt;/p&gt;
&lt;p&gt;Therefore, the Fourier series for such &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/945519cc8666a0a6bfd3a390a10cd7fb2facc3bc.svg" style="height: 19px;" type="image/svg+xml"&gt;f_e(x)&lt;/object&gt; is a &lt;em&gt;cosine
series&lt;/em&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/abf9730ce5c3f88d7dedd5fbfa57a0b725b7f0d7.svg" style="height: 49px;" type="image/svg+xml"&gt;\[f_e(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}a_n cos\frac{n\pi x}{L}\]&lt;/object&gt;
&lt;p&gt;With coefficients &lt;img alt="a_0" class="valign-m3" src="https://eli.thegreenplace.net/images/math/4a5997da73aadd118038761e69d01e24586bf958.png" style="height: 11px;" /&gt; and &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/278ab95d3a54aae8eaa25c34af66d93a19b5e75f.svg" style="height: 11px;" type="image/svg+xml"&gt;a_n&lt;/object&gt; given as before.&lt;/p&gt;
&lt;p&gt;Similarly if &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7616404fc7a2da1d8602d2c3ed0da2e99e4fb021.svg" style="height: 19px;" type="image/svg+xml"&gt;f_o(x)&lt;/object&gt; is an &lt;em&gt;odd&lt;/em&gt; function, then its &lt;img alt="a_0" class="valign-m3" src="https://eli.thegreenplace.net/images/math/4a5997da73aadd118038761e69d01e24586bf958.png" style="height: 11px;" /&gt;
and &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/278ab95d3a54aae8eaa25c34af66d93a19b5e75f.svg" style="height: 11px;" type="image/svg+xml"&gt;a_n&lt;/object&gt; are 0, and its Fourier series is a &lt;em&gt;sine series&lt;/em&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/a4517fb01f03c4e5b739f7c626668c3b804c5efc.svg" style="height: 49px;" type="image/svg+xml"&gt;\[f_o(x)=\sum_{n=1}^{\infty}b_n sin\frac{n\pi x}{L}\]&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="fourier-series-for-a-non-periodic-function-defined-on-an-interval"&gt;
&lt;h2&gt;Fourier series for a non-periodic function defined on an interval&lt;/h2&gt;
&lt;p&gt;So far we’ve been talking about &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/8dde33545500de38fae974b4b18036def142e9e3.svg" style="height: 12px;" type="image/svg+xml"&gt;2L&lt;/object&gt;-periodic functions that can
be faithfully represented by Fourier series. But what if we have a
non-periodic function defined on a finite interval?&lt;/p&gt;
&lt;p&gt;E.g. suppose we have &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/f1dbdd3a5b38fafd9f78c329171bfe72dea6faf8.svg" style="height: 19px;" type="image/svg+xml"&gt;f(x)=x&lt;/object&gt; on the interval &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/6341a223ef0a566153beb0037d5a48d2d4b9d0eb.svg" style="height: 18px;" type="image/svg+xml"&gt;[0,L]&lt;/object&gt;. Can
we approximate it with a Fourier series?&lt;/p&gt;
&lt;p&gt;Yes! First, we have to make a choice of how to extend the function to
the negative interval &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/e345009799354a67cfdba7a7a8ea8ac4acb4d269.svg" style="height: 18px;" type="image/svg+xml"&gt;[-L,0]&lt;/object&gt;. Then, we simply repeat the
function every &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/8dde33545500de38fae974b4b18036def142e9e3.svg" style="height: 12px;" type="image/svg+xml"&gt;2L&lt;/object&gt; - this is called a &lt;em&gt;periodic extension&lt;/em&gt;. Note
that the Fourier series calculation only cares about the range
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/5f1297a5a8758acc19fd4c325ae19878e7e2fbab.svg" style="height: 18px;" type="image/svg+xml"&gt;[-L,L]&lt;/object&gt;. The resulting series will approximate the generated
periodic function in its entirety, and in particular will also converge
to it in the &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/6341a223ef0a566153beb0037d5a48d2d4b9d0eb.svg" style="height: 18px;" type="image/svg+xml"&gt;[0,L]&lt;/object&gt; interval (except maybe the endpoints,
depending on the mode of extension).&lt;/p&gt;
&lt;p&gt;There are several natural ways to extend a function defined on
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/6341a223ef0a566153beb0037d5a48d2d4b9d0eb.svg" style="height: 18px;" type="image/svg+xml"&gt;[0,L]&lt;/object&gt; into the interval &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/e345009799354a67cfdba7a7a8ea8ac4acb4d269.svg" style="height: 18px;" type="image/svg+xml"&gt;[-L,0]&lt;/object&gt; &lt;a class="footnote-reference" href="#footnote-3" id="footnote-reference-3"&gt;[3]&lt;/a&gt;:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Direct periodic repetition: we simply repeat &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; every
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/d160e0986aca4714714a16f29ec605af90be704d.svg" style="height: 12px;" type="image/svg+xml"&gt;L&lt;/object&gt;: &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/2168e6b40692df7e2d65d2c56516bd3161cf949b.svg" style="height: 19px;" type="image/svg+xml"&gt;f(x+L)=f(x)\ \forall x&lt;/object&gt;.&lt;/li&gt;
&lt;li&gt;Even extension: &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7e3975e4586db92c8a5b4b1066af313951344cc0.svg" style="height: 19px;" type="image/svg+xml"&gt;f(|x|)&lt;/object&gt;&lt;/li&gt;
&lt;li&gt;Odd extension: &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; when &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/e7fbdc98286846014db4fa4f5ef46d5d976c75d5.svg" style="height: 15px;" type="image/svg+xml"&gt;x\ge 0&lt;/object&gt; and
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/3c4482de6e0520991510d97cf67550d03e9e813b.svg" style="height: 19px;" type="image/svg+xml"&gt;-f(-x)&lt;/object&gt; when &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/92e0c7b6f34838a90088599672030c1921292807.svg" style="height: 14px;" type="image/svg+xml"&gt;x&amp;lt;0&lt;/object&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here’s an example of extending our sample function &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/f1dbdd3a5b38fafd9f78c329171bfe72dea6faf8.svg" style="height: 19px;" type="image/svg+xml"&gt;f(x)=x&lt;/object&gt; onto
the full interval &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/5f1297a5a8758acc19fd4c325ae19878e7e2fbab.svg" style="height: 18px;" type="image/svg+xml"&gt;[-L,L]&lt;/object&gt; and then repeating it periodically
every &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/8dde33545500de38fae974b4b18036def142e9e3.svg" style="height: 12px;" type="image/svg+xml"&gt;2L&lt;/object&gt;:&lt;/p&gt;
&lt;div class="fourier-plot-wrap"&gt;
  &lt;canvas id="function-extensions" class="fourier-plot-canvas" width="760" height="1280"&gt;
  Your browser does not support the HTML5 canvas tag.
  &lt;/canvas&gt;
&lt;/div&gt;&lt;p&gt;Note that the Fourier series for these extended functions will be
different. However, they will all converge to &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; in the
interval &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/6341a223ef0a566153beb0037d5a48d2d4b9d0eb.svg" style="height: 18px;" type="image/svg+xml"&gt;[0,L]&lt;/object&gt;. Typically, even and odd extensions have the
benefit of producing either cosine or sine series, correspondingly (as
discussed in the previous section).&lt;/p&gt;
&lt;p&gt;We’ve seen that Fourier series work well for periodic functions and also
non-periodic functions defined on a finite domain (because we can extend
these periodically). But what about aperiodic functions defined on the
entire real line? This is where we’ll have to leave Fourier series
behind and move on to their generalization - the &lt;em&gt;Fourier transform&lt;/em&gt;;
this will be a topic for a separate post.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="example"&gt;
&lt;h2&gt;Example&lt;/h2&gt;
&lt;p&gt;Let’s take the following triangular function &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/75a7147566fd4ba98fe5d85fe008fab6d58d3968.svg" style="height: 19px;" type="image/svg+xml"&gt;t(x)&lt;/object&gt; &lt;a class="footnote-reference" href="#footnote-4" id="footnote-reference-4"&gt;[4]&lt;/a&gt;:&lt;/p&gt;
&lt;div class="fourier-plot-wrap"&gt;
  &lt;canvas id="triangle-wave" class="fourier-plot-canvas" width="760" height="510"&gt;
  Your browser does not support the HTML5 canvas tag.
  &lt;/canvas&gt;
&lt;/div&gt;&lt;p&gt;&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/75a7147566fd4ba98fe5d85fe008fab6d58d3968.svg" style="height: 19px;" type="image/svg+xml"&gt;t(x)&lt;/object&gt; is periodic with period 4. We can define it by starting
with a formula on the interval &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/4223e7fe7292caec8543b085e1c5e0f283d99e07.svg" style="height: 18px;" type="image/svg+xml"&gt;[0,2]&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/219270dd9765adc74c363412ff71219137e90f0c.svg" style="height: 54px;" type="image/svg+xml"&gt;\[t(x)=
\begin{cases}
    x     &amp;amp;  0 \leq x \leq 1 \\
    2-x   &amp;amp;  1 &amp;lt; x \leq 2  \\
\end{cases}\]&lt;/object&gt;
&lt;p&gt;Then making an odd extension into &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/8291e9956dc145c0d40503664cdb2aa8907faeec.svg" style="height: 18px;" type="image/svg+xml"&gt;[-2,0]&lt;/object&gt; and repeating it
periodically. Now we can go ahead to calculate its Fourier coefficients.&lt;/p&gt;
&lt;p&gt;Since this function is odd, we know that we’ll get a &lt;em&gt;sine series&lt;/em&gt;, as
&lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/278ab95d3a54aae8eaa25c34af66d93a19b5e75f.svg" style="height: 11px;" type="image/svg+xml"&gt;a_n&lt;/object&gt; are going to be 0 for all &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt;. Let’s calculate
&lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/54d608cbef1529c3089b9281aa6dcb16a2e65f1f.svg" style="height: 15px;" type="image/svg+xml"&gt;b_n&lt;/object&gt;; in our case &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/61b388ffea23456a34a8c200e35a624fb3500600.svg" style="height: 12px;" type="image/svg+xml"&gt;L=2&lt;/object&gt; (half the period).&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/842ae33a5aa7760177bcac4d6a4ce14bdb3ad3a3.svg" style="height: 44px;" type="image/svg+xml"&gt;\[b_n=\frac{1}{2}\int_{-2}^{2}t(x)sin\frac{n\pi x}{2}dx\]&lt;/object&gt;
&lt;p&gt;Since &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/75a7147566fd4ba98fe5d85fe008fab6d58d3968.svg" style="height: 19px;" type="image/svg+xml"&gt;t(x)&lt;/object&gt; is odd and so is the sine, we’re integrating an even
function over a symmetric interval. Therefore, we only have to integrate
on the positive half of the range and multiply the result by two:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/d434617a027c2c9c6c40fda3d5df9efd71d9da5e.svg" style="height: 44px;" type="image/svg+xml"&gt;\[b_n=\int_{0}^{2}t(x)sin\frac{n\pi x}{2}dx\]&lt;/object&gt;
&lt;p&gt;Let’s set &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/0845fe4b9330ab55e9477397cf6a0372b91d9490.svg" style="height: 19px;" type="image/svg+xml"&gt;k=\frac{n\pi}{2}&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/da138d7dfb7e49cbba7719c34fa84063eacac079.svg" style="height: 44px;" type="image/svg+xml"&gt;\[b_n=\int_{0}^{2}t(x)sin(kx)dx\]&lt;/object&gt;
&lt;p&gt;And split up the integral for the different segments of &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/75a7147566fd4ba98fe5d85fe008fab6d58d3968.svg" style="height: 19px;" type="image/svg+xml"&gt;t(x)&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/c520bcc563be425bf5eca3c72ccc1dd315148e9d.svg" style="height: 44px;" type="image/svg+xml"&gt;\[b_n=\int_{0}^{1}x\cdot sin(kx)dx+\int_{1}^{2}(2-x)sin(kx)dx\]&lt;/object&gt;
&lt;p&gt;The first integral, by the method described in Appendix C:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/f0ab0ff7e24e7e2488aca6dc7b26a5876f95edca.svg" style="height: 48px;" type="image/svg+xml"&gt;\[I_1=\int_{0}^{1}x\cdot sin(kx)dx=\bigg[\frac{-x cos(kx)}{k}+\frac{sin(kx)}{k^2} \bigg]_{0}^{1}=\frac{sin(k)}{k^2}-\frac{cos(k)}{k}\]&lt;/object&gt;
&lt;p&gt;The second integral can also be split into two:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/f9bbd9960bbe4f5b7689ca32176c299b111ba79c.svg" style="height: 44px;" type="image/svg+xml"&gt;\[I_2=\int_{1}^{2}2sin(kx)dx - \int_{1}^{2}x\cdot sin(kx)dx\]&lt;/object&gt;
&lt;p&gt;The first of these is trivial to calculate; the second can once again
use Appendix C. After some tedious but straightforward calculations &lt;a class="footnote-reference" href="#footnote-5" id="footnote-reference-5"&gt;[5]&lt;/a&gt;
we’ll get:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/adac1720b14c2fe0786b54bc27aae1aef0fbef48.svg" style="height: 38px;" type="image/svg+xml"&gt;\[I_2=\frac{cos(k)}{k}+\frac{sin(k)-sin(2k)}{k^2}\]&lt;/object&gt;
&lt;p&gt;Adding &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/e1d59f2ede2e9c62de3e7071e2f8fe5034aed288.svg" style="height: 15px;" type="image/svg+xml"&gt;I_1+I_2&lt;/object&gt;, we get:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/15e4c796f5a29a762fec37d78ae7c706f4be0ea5.svg" style="height: 83px;" type="image/svg+xml"&gt;\[\begin{aligned}
b_n=I_1+I_2&amp;amp;=\frac{sin(k)}{k^2}-\frac{cos(k)}{k}+\frac{cos(k)}{k}+\frac{sin(k)-sin(2k)}{k^2}\\
&amp;amp;=\frac{2sin(k)-sin(2k)}{k^2}
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Now let’s substitute &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/0845fe4b9330ab55e9477397cf6a0372b91d9490.svg" style="height: 19px;" type="image/svg+xml"&gt;k=\frac{n\pi}{2}&lt;/object&gt; back. This makes
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/bb77ea3f09c1bd70e8755e99c100f6240fbbaee2.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(2k)&lt;/object&gt; zero because the sine of an integer multiple of
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/6ac47b6d7372b4087583cfd048d20f4c1571f5cf.svg" style="height: 8px;" type="image/svg+xml"&gt;\pi&lt;/object&gt; is always zero:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/0dd6f332d6b02605b05f4ec20712ba682a73f754.svg" style="height: 49px;" type="image/svg+xml"&gt;\[b_n=\frac{2sin \frac{n\pi}{2}}{\left (\frac{n\pi}{2}\right )^2}=\frac{8sin \frac{n\pi}{2}}{n^2\pi^2}\]&lt;/object&gt;
&lt;p&gt;We have &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/54d608cbef1529c3089b9281aa6dcb16a2e65f1f.svg" style="height: 15px;" type="image/svg+xml"&gt;b_n&lt;/object&gt;, so the Fourier series for our &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/75a7147566fd4ba98fe5d85fe008fab6d58d3968.svg" style="height: 19px;" type="image/svg+xml"&gt;t(x)&lt;/object&gt; is:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/c3d02d270ba13c4401ff78e0d65bbab33d27fa8f.svg" style="height: 49px;" type="image/svg+xml"&gt;\[t(x)=\sum_{n=1}^{\infty}\frac{8}{n^2\pi^2}sin\frac{n\pi}{2}sin\frac{n\pi x}{2}\]&lt;/object&gt;
&lt;p&gt;Note that for even values of &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt;, &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/4285416a9a4c5ba91639c3d1f777c6de55ce72c2.svg" style="height: 19px;" type="image/svg+xml"&gt;sin \frac{n\pi}{2}&lt;/object&gt; is
zero, so only the odd terms remain:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/7942a20004aaf07d850b012826c56720f6efa3ce.svg" style="height: 42px;" type="image/svg+xml"&gt;\[t(x)=\frac{8}{\pi^2}\bigg[ sin\frac{\pi x}{2}-\frac{1}{3^2} sin\frac{3\pi x}{2}+\frac{1}{5^2}sin\frac{5\pi x}{2}-\cdots\bigg]\]&lt;/object&gt;
&lt;p&gt;Here’s an interactive chart showing how the series &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/75a7147566fd4ba98fe5d85fe008fab6d58d3968.svg" style="height: 19px;" type="image/svg+xml"&gt;t(x)&lt;/object&gt;
converges to our triangular function. You can set the number of terms in
the Fourier series and see the effect (red line). Note that all even
coefficients are zero so it will look the same for &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt; as for
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/81f998c5713fded10a77db292e4114ec87997543.svg" style="height: 12px;" type="image/svg+xml"&gt;n-1&lt;/object&gt; when &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt; is odd.&lt;/p&gt;
&lt;div class="fourier-plot-wrap"&gt;
  &lt;canvas id="triangle-fourier" class="fourier-plot-canvas" width="760" height="510"&gt;
  Your browser does not support the HTML5 canvas tag.
  &lt;/canvas&gt;

  &lt;div class="fourier-plot-controls"&gt;
    &lt;div class="fourier-plot-grid"&gt;
      &lt;label class="fourier-plot-label" for="triangle-fourier-terms"&gt;
        n (terms in the Fourier series)
        &lt;input id="triangle-fourier-terms" class="fourier-plot-input" type="number" value="1" min="1" max="99" step="2"&gt;
      &lt;/label&gt;
    &lt;/div&gt;

    &lt;div id="triangle-fourier-message" class="fourier-plot-message"&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;div class="section" id="compact-formula-using-a-single-phase-shifted-sinusoid"&gt;
&lt;h2&gt;Compact formula using a single phase-shifted sinusoid&lt;/h2&gt;
&lt;p&gt;We’ve written the Fourier series for &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; as follows so far:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/af4acda237be7c5348b05201f8f6f6c6b75e30b9.svg" style="height: 49px;" type="image/svg+xml"&gt;\[f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}\left(a_n cos\frac{n\pi x}{L}+b_n sin\frac{n\pi x}{L}\right)\]&lt;/object&gt;
&lt;p&gt;We can rewrite this in a somewhat more compact form, using a single
sinusoid with a configurable phase at each &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/0e0b529f628f772b5448c6ec96e6d5884885480b.svg" style="height: 49px;" type="image/svg+xml"&gt;\[f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}q_n\cdot cos\left(\frac{n\pi x}{L}+\theta_n\right)\]&lt;/object&gt;
&lt;p&gt;Based on Appendix D, &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/0dacaea006b7f9f49020f85f9803b4467a77094b.svg" style="height: 12px;" type="image/svg+xml"&gt;q_n&lt;/object&gt; and &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/7dde5e64e049b615293b3dd8f94a70defa6a789b.svg" style="height: 15px;" type="image/svg+xml"&gt;\theta_n&lt;/object&gt; can be computed as
follows:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/dfca335ac97ffd88dc5a83a1ae48576dfa84d8b7.svg" style="height: 49px;" type="image/svg+xml"&gt;\[\begin{aligned}
    q_n&amp;amp;=\sqrt{a_n^2+b_n^2}\\
    \theta_n&amp;amp;=\operatorname{atan2}(-b_n,a_n)
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;When Fourier series are used in the context of signal processing, this
formulation is easier to reason about because it represents the
magnitude and phase shift of each harmonic of &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; in the
frequency domain &lt;a class="footnote-reference" href="#footnote-6" id="footnote-reference-6"&gt;[6]&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="complex-fourier-series"&gt;
&lt;h2&gt;Complex Fourier series&lt;/h2&gt;
&lt;p&gt;It should not come as a surprise that the Fourier series, being a
combination of trigonometric functions, can also be represented with
complex exponential functions.&lt;/p&gt;
&lt;p&gt;Specifically, we’ll show that our &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; can be approximated as
follows:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/0330fae433a3379cfef316d192bfe32e38e0c9c9.svg" style="height: 48px;" type="image/svg+xml"&gt;\[f(x)=\sum_{n=-\infty}^{\infty}C_n\cdot e^{in\pi x/L}\]&lt;/object&gt;
&lt;p&gt;Let’s calculate &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/e6456786af3c999a8eda7658e37f7bf5d1bb0db0.svg" style="height: 15px;" type="image/svg+xml"&gt;C_n&lt;/object&gt;. We proceed in a manner similar to before,
by multiplying both sides of the equation by &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/e8594d0018e4f868e916c1657b8273bb9bfe2191.svg" style="height: 16px;" type="image/svg+xml"&gt;e^{-im\pi x/L}&lt;/object&gt; and
taking an integral in the range &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/5f1297a5a8758acc19fd4c325ae19878e7e2fbab.svg" style="height: 18px;" type="image/svg+xml"&gt;[-L,L]&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/f0a6b29c21ad20ebd950fe01f05b43c1fa67aa22.svg" style="height: 108px;" type="image/svg+xml"&gt;\[\begin{aligned}
\int_{-L}^{L}f(x)e^{-im\pi x/L}dx&amp;amp;=\sum_{n=-\infty}^{\infty}\int_{-L}^{L}C_n\cdot e^{in\pi x/L}e^{-im\pi x/L}dx\\
&amp;amp;=\sum_{n=-\infty}^{\infty}\int_{-L}^{L}C_n\cdot e^{i(n-m)\pi x/L}dx
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;By Appendix A, the sum elements are all zero when &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/3ae4a06555822644174f9ff9419084466b3f7aa4.svg" style="height: 17px;" type="image/svg+xml"&gt;n\neq m&lt;/object&gt;. When
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/193bdae8b42385001cd707bc207b1d95bd6dc2b2.svg" style="height: 8px;" type="image/svg+xml"&gt;n=m&lt;/object&gt;, we get:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/e67fe1e7dabb9b96c06224e0d785d9a6d17601c4.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\int_{-L}^{L}f(x)e^{-im\pi x/L}dx=\int_{-L}^{L}C_m\cdot 1 \cdot dx=2LC_m\]&lt;/object&gt;
&lt;p&gt;Therefore, renaming &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/6b0d31c0d563223024da45691584643ac78c96e8.svg" style="height: 8px;" type="image/svg+xml"&gt;m&lt;/object&gt; to &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt; (since it’s just an arbitrary
integer constant):&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/d70fa4e75b4b604398d8d3c108a75bea622e72ef.svg" style="height: 44px;" type="image/svg+xml"&gt;\[C_n=\frac{1}{2L}\int_{-L}^{L}f(x)e^{-in\pi x/L}dx\]&lt;/object&gt;
&lt;p&gt;We’ve found an alternative formulation to Fourier series, using complex
exponentials instead of trigonometric functions. While this was a direct
derivation, another way to achieve the same result is to use the &lt;a class="reference external" href="https://eli.thegreenplace.net/2024/notes-on-the-euler-formula/"&gt;Euler
Formula&lt;/a&gt;
to derive:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/421172c9cfae4c087883b04c9d6c047b8c2a03e9.svg" style="height: 86px;" type="image/svg+xml"&gt;\[\begin{aligned}
    cos\theta&amp;amp;=\frac{e^{i\theta}+e^{-i\theta}}{2}\\
    sin\theta&amp;amp;=\frac{e^{i\theta}-e^{-i\theta}}{2i}
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;And substitute these into the original Fourier series formula. I’ll
leave this as an exercise for the diligent reader; eventually, the
result will be the same. Moreover, it’s possible to show a direct
correspondence between &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/278ab95d3a54aae8eaa25c34af66d93a19b5e75f.svg" style="height: 11px;" type="image/svg+xml"&gt;a_n&lt;/object&gt;, &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/54d608cbef1529c3089b9281aa6dcb16a2e65f1f.svg" style="height: 15px;" type="image/svg+xml"&gt;b_n&lt;/object&gt; and &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/e6456786af3c999a8eda7658e37f7bf5d1bb0db0.svg" style="height: 15px;" type="image/svg+xml"&gt;C_n&lt;/object&gt;, for
&lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/98b4f7b1f9e3613bfd676d3fdee9cd7b3b3f2a93.svg" style="height: 14px;" type="image/svg+xml"&gt;n&amp;gt;0&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/5f31bd78b45bb047f333a4257d8aa79cede582cd.svg" style="height: 118px;" type="image/svg+xml"&gt;\[\begin{aligned}
    C_0&amp;amp;=\frac{a_0}{2}\\
    C_n&amp;amp;=\frac{a_n-ib_n}{2}\\
    C_{-n}&amp;amp;=\frac{a_n+ib_n}{2}\\
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Note that &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/0bd1272b8272095400c72ab3f5bd52378bef592e.svg" style="height: 16px;" type="image/svg+xml"&gt;C_{-n}=C_n^*&lt;/object&gt; when both &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/278ab95d3a54aae8eaa25c34af66d93a19b5e75f.svg" style="height: 11px;" type="image/svg+xml"&gt;a_n&lt;/object&gt; and &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/54d608cbef1529c3089b9281aa6dcb16a2e65f1f.svg" style="height: 15px;" type="image/svg+xml"&gt;b_n&lt;/object&gt; are
real (which is the case for a real-valued &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt;). This helps
explain why the complex formulation has negative frequencies in the sum;
when the function is actually real, each negative frequency is paired up
with a positive frequency and the result is real &lt;a class="footnote-reference" href="#footnote-7" id="footnote-reference-7"&gt;[7]&lt;/a&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/530d1067a8b3fa34b5cc74abccb738a58540022a.svg" style="height: 112px;" type="image/svg+xml"&gt;\[\begin{aligned}
C_n e^{in\pi x/L}+C_{-n} e^{-in\pi x/L}&amp;amp;=C_n e^{in\pi x/L}+C_n^* e^{-in\pi x/L}\\
&amp;amp;=C_n e^{in\pi x/L}+\left(C_{n} e^{in\pi x/L}\right)^*\\
&amp;amp;=2\operatorname{Re}\bigg(C_{n} e^{in\pi x/L}\bigg)
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;So, for a real function we only need to account for positive
frequencies:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/1e0faa05c55997d3b0f2c58c8bb16dca0b701fd0.svg" style="height: 49px;" type="image/svg+xml"&gt;\[f(x)=C_0+\sum_{n=1}^{\infty}2\operatorname{Re}\bigg(C_{n} e^{in\pi x/L}\bigg)\]&lt;/object&gt;
&lt;p&gt;We can take it further. &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/e6456786af3c999a8eda7658e37f7bf5d1bb0db0.svg" style="height: 15px;" type="image/svg+xml"&gt;C_n&lt;/object&gt; is a complex number, so let’s
represent it in polar form as &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/1a21212523d9fce12a0769bdee7b76db92fd7e64.svg" style="height: 21px;" type="image/svg+xml"&gt;C_n=\frac{q_n}{2} e^{i\theta_n}&lt;/object&gt;
(the factor of half will make sense soon). Then:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/06c843ccf5621a53bd6a5c9cee599cfabbdc2a85.svg" style="height: 141px;" type="image/svg+xml"&gt;\[\begin{aligned}
\operatorname{Re}\bigg(C_{n} e^{in\pi x/L}\bigg)&amp;amp;=\operatorname{Re}\bigg(\frac{q_n}{2} e^{i\theta_n}e^{in\pi x/L}\bigg)\\
&amp;amp;=\frac{q_n}{2}\operatorname{Re}\bigg(e^{i(n\pi x/L + \theta_n)}\bigg)\\
&amp;amp;=\frac{q_n}{2} cos\bigg(\frac{n\pi x}{L}+\theta_n\bigg)
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;And substituting back into the sum:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/c6d0bb12eb5cc2fbb7f881c0ecf8fcf0f700eeda.svg" style="height: 49px;" type="image/svg+xml"&gt;\[f(x)=C_0+\sum_{n=1}^{\infty}q_n cos\bigg(\frac{n\pi x}{L}+\theta_n\bigg)\]&lt;/object&gt;
&lt;p&gt;This is precisely the compact formulation from the previous section!&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="fourier-orthogonal-basis-in-hilbert-space"&gt;
&lt;h2&gt;Fourier orthogonal basis in Hilbert space&lt;/h2&gt;
&lt;p&gt;The most beautiful aspect of Fourier theory is that it doesn’t just
happen to work by chance, and is deeply connected to linear algebra.
Please read &lt;a class="reference external" href="https://eli.thegreenplace.net/2025/hilbert-space-treating-functions-as-vectors/"&gt;my post on Hilbert
space&lt;/a&gt;
before proceeding.&lt;/p&gt;
&lt;p&gt;The space of real-valued square integrable functions &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/f1aae083af2c79348dd78712847ebd55537fa6e6.svg" style="height: 15px;" type="image/svg+xml"&gt;L^2&lt;/object&gt; forms a
Hilbert space, in which we can define the inner product (assuming real
functions):&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/979d2b712d89bac8c7950b7b13ecf0b895422989.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\langle f,g \rangle=\int_{-L}^{L}f(x)g(x) dx\]&lt;/object&gt;
&lt;p&gt;We’ve demonstrated that the family of functions:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/f4bd9b77b937cf139ca1c071a6783fcdeafdd8cf.svg" style="height: 32px;" type="image/svg+xml"&gt;\[1,\qquad cos\frac{n\pi x}{L},\qquad sin\frac{n\pi x}{L}\]&lt;/object&gt;
&lt;p&gt;Are all mutually orthogonal, because their pairwise inner products are
zero! We’ve also shown that any function in &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/f1aae083af2c79348dd78712847ebd55537fa6e6.svg" style="height: 15px;" type="image/svg+xml"&gt;L^2&lt;/object&gt; can be
represented as a weighted sum of these functions:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/af4acda237be7c5348b05201f8f6f6c6b75e30b9.svg" style="height: 49px;" type="image/svg+xml"&gt;\[f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}\left(a_n cos\frac{n\pi x}{L}+b_n sin\frac{n\pi x}{L}\right)\]&lt;/object&gt;
&lt;p&gt;So these functions form a &lt;em&gt;basis&lt;/em&gt; for &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/f1aae083af2c79348dd78712847ebd55537fa6e6.svg" style="height: 15px;" type="image/svg+xml"&gt;L^2&lt;/object&gt;. When we think of
these functions as vectors (in an infinite Hilbert space), much of what
we did in this post starts feeling like &amp;quot;normal&amp;quot; linear algebra. For
example, when we have a set of basis vectors and we want to know how to
represent some vector &lt;img alt="v" class="valign-0" src="https://eli.thegreenplace.net/images/math/7a38d8cbd20d9932ba948efaa364bb62651d5ad4.png" style="height: 8px;" /&gt; in this basis, we usually find the
coefficients by &lt;a class="reference external" href="https://eli.thegreenplace.net/2024/projections-and-projection-matrices/"&gt;projecting
it&lt;/a&gt;
onto the basis. E.g. with a basis vector &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/da8e9997a010be78b20108ce79fec1fb9c63d8dc.svg" style="height: 11px;" type="image/svg+xml"&gt;e_1&lt;/object&gt;, the coefficient of
&lt;img alt="v" class="valign-0" src="https://eli.thegreenplace.net/images/math/7a38d8cbd20d9932ba948efaa364bb62651d5ad4.png" style="height: 8px;" /&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/71b725179f33404ddc381f57d651c348ddfbee36.svg" style="height: 43px;" type="image/svg+xml"&gt;\[c=\frac{\langle v, e_1\rangle}{\langle e_1, e_1\rangle}\]&lt;/object&gt;
&lt;p&gt;Similarly, when we calculate the coefficient &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/54d608cbef1529c3089b9281aa6dcb16a2e65f1f.svg" style="height: 15px;" type="image/svg+xml"&gt;b_n&lt;/object&gt; for some
function &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt;, we project &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; onto the basis vector
&lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/08cb570d61f7bb6f46cf3bf12e2c407a43e748b8.svg" style="height: 19px;" type="image/svg+xml"&gt;sin\frac{n\pi x}{L}&lt;/object&gt; by calculating:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/40fddd72747ac208870cfe3ee684128d21812cfa.svg" style="height: 45px;" type="image/svg+xml"&gt;\[b_n=\frac{\langle f(x), sin\frac{n\pi x}{L}\rangle}{\langle sin\frac{n\pi x}{L}, sin\frac{n\pi x}{L}\rangle}\]&lt;/object&gt;
&lt;p&gt;From Appendix B, we know that the denominator is &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/d160e0986aca4714714a16f29ec605af90be704d.svg" style="height: 12px;" type="image/svg+xml"&gt;L&lt;/object&gt;, and we’ve
just denoted:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/fc0911ff039b636dc0b1f9ae9cc804c68cab812d.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\langle f(x), sin\frac{n\pi x}{L}\rangle=\int_{-L}^{L}f(x)sin\frac{n\pi x}{L}dx\]&lt;/object&gt;
&lt;p&gt;So we get:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/418eef7e6ac0ffd84fc9d87246f1329d17cb6d4c.svg" style="height: 44px;" type="image/svg+xml"&gt;\[b_n=\frac{1}{L}\int_{-L}^{L}f(x)sin\frac{n\pi x}{L}dx\]&lt;/object&gt;
&lt;p&gt;Which should look familiar!&lt;/p&gt;
&lt;p&gt;This is the core linear-algebra idea behind Fourier series: the
functions &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/356a192b7913b04c54574d18c28d46e6395428ab.svg" style="height: 12px;" type="image/svg+xml"&gt;1&lt;/object&gt;, &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/0141773559b36de7a9e12feb64f961177df6b9d5.svg" style="height: 19px;" type="image/svg+xml"&gt;cos\frac{n\pi x}{L}&lt;/object&gt;, and
&lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/08cb570d61f7bb6f46cf3bf12e2c407a43e748b8.svg" style="height: 19px;" type="image/svg+xml"&gt;sin\frac{n\pi x}{L}&lt;/object&gt; play the role of orthogonal basis vectors,
while the Fourier coefficients are coordinates of &lt;img alt="f" class="valign-m4" src="https://eli.thegreenplace.net/images/math/4a0a19218e082a343a1b17e5333409af9d98f0f5.png" style="height: 16px;" /&gt; in this
basis. The integral formulas for &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/278ab95d3a54aae8eaa25c34af66d93a19b5e75f.svg" style="height: 11px;" type="image/svg+xml"&gt;a_n&lt;/object&gt; and &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/54d608cbef1529c3089b9281aa6dcb16a2e65f1f.svg" style="height: 15px;" type="image/svg+xml"&gt;b_n&lt;/object&gt; are not
mysterious tricks; they are projections, just like dot products with
basis vectors in ordinary Euclidean space.&lt;/p&gt;
&lt;p&gt;Fourier series therefore let us decompose a function into independent
orthogonal directions, much like decomposing a vector into its
&lt;img alt="x" class="valign-0" src="https://eli.thegreenplace.net/images/math/11f6ad8ec52a2984abaafd7c3b516503785c2072.png" style="height: 8px;" /&gt;, &lt;img alt="y" class="valign-m4" src="https://eli.thegreenplace.net/images/math/95cb0bfd2977c761298d9624e4b4d4c72a39974a.png" style="height: 12px;" /&gt;, and &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/395df8f7c51f007019cb30201c49e884b46b92fa.svg" style="height: 8px;" type="image/svg+xml"&gt;z&lt;/object&gt; components.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="appendix-a-integrals-of-sinusoids"&gt;
&lt;h2&gt;Appendix A: Integrals of sinusoids&lt;/h2&gt;
&lt;p&gt;For any integer &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/797c9948b82583001e2fe0e9343c783ca16709b0.svg" style="height: 17px;" type="image/svg+xml"&gt;n\neq 0&lt;/object&gt; and an arbitrary constant L, we have:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/582e940109a028f515a388f8003ebfbb00823dd3.svg" style="height: 92px;" type="image/svg+xml"&gt;\[\begin{aligned}
\int_{-L}^{L}cos\frac{n\pi x}{L}dx&amp;amp;=\bigg[\frac{L}{n\pi}sin\frac{n\pi x}{L}\bigg]_{-L}^{L}\\
&amp;amp;=\frac{L}{n\pi}(sin(n\pi)-sin(-n\pi))=0
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Similarly:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/f5220d0714489c00c6ec8c5ac2df22bf8d8cb1f4.svg" style="height: 92px;" type="image/svg+xml"&gt;\[\begin{aligned}
\int_{-L}^{L}sin\frac{n\pi x}{L}dx&amp;amp;=\bigg[\frac{-L}{n\pi}cos\frac{n\pi x}{L}\bigg]_{-L}^{L}\\
&amp;amp;=\frac{-L}{n\pi}\left(cos(n\pi)-cos(-n\pi)\right)=0
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Using these, we can calculate the integral of a complex exponential
function for an integer &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/797c9948b82583001e2fe0e9343c783ca16709b0.svg" style="height: 17px;" type="image/svg+xml"&gt;n\neq 0&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/3ae1815e617e0b0191a17fa9b07196ededfaf901.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\begin{aligned}
\int_{-L}^{L}e^{in\pi x/L}dx=\int_{-L}^{L}\bigg[ cos\frac{n\pi x}{L} +i\cdot sin\frac{n\pi x}{L}\bigg] dx=0
\end{aligned}\]&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="appendix-b-integrals-of-products-of-sinusoids"&gt;
&lt;h2&gt;Appendix B: Integrals of products of sinusoids&lt;/h2&gt;
&lt;p&gt;We’ll start with the product of two sines, for any positive integers
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/6b0d31c0d563223024da45691584643ac78c96e8.svg" style="height: 8px;" type="image/svg+xml"&gt;m&lt;/object&gt; and &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/e95f65d1c2626cffbdb8e474676708ef6ca38278.svg" style="height: 44px;" type="image/svg+xml"&gt;\[ss=\int_{-L}^{L}sin\frac{m\pi x}{L}\cdot sin\frac{n\pi x}{L}dx\]&lt;/object&gt;
&lt;p&gt;Using the trigonometric identity for a product of sines, we can write:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/06a26e4d08d086b4e29b1c23a918009d9f03886c.svg" style="height: 96px;" type="image/svg+xml"&gt;\[\begin{aligned}
    ss&amp;amp;=\frac{1}{2}\int_{-L}^{L}\bigg(cos\frac{(m-n)\pi x}{L}-cos\frac{(m+n)\pi x}{L}\bigg)dx\\
    &amp;amp;=\frac{1}{2}\int_{-L}^{L}cos\frac{(m-n)\pi x}{L}dx-\frac{1}{2}\int_{-L}^{L}cos\frac{(m+n)\pi x}{L}dx
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Now let’s focus on two different scenarios, &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/c21c6fe891018692f0717e8f38fbd44941a8ab7c.svg" style="height: 17px;" type="image/svg+xml"&gt;m\neq n&lt;/object&gt; and
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/49cfc75f5c423bc73e28d59b794e2815d1f4bb54.svg" style="height: 8px;" type="image/svg+xml"&gt;m=n&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;If &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/c21c6fe891018692f0717e8f38fbd44941a8ab7c.svg" style="height: 17px;" type="image/svg+xml"&gt;m\neq n&lt;/object&gt;, then each of the integrals constituting &lt;em&gt;ss&lt;/em&gt; are 0
(see on Appendix A), so &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/19db77825a7cd28d0344f9b160251f8230d08b30.svg" style="height: 12px;" type="image/svg+xml"&gt;ss=0&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;If &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/49cfc75f5c423bc73e28d59b794e2815d1f4bb54.svg" style="height: 8px;" type="image/svg+xml"&gt;m=n&lt;/object&gt;, then the second integral is still 0, but the first one
isn’t:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/024afeb4e1aa17cd4cf9bfc70fdf0d9d09be7faf.svg" style="height: 96px;" type="image/svg+xml"&gt;\[\begin{aligned}
    ss&amp;amp;=\frac{1}{2}\int_{-L}^{L}cos\frac{0\pi x}{L}dx\\
    &amp;amp;=\frac{1}{2}\int_{-L}^{L}1dx=L
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Therefore:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/85dbc4cbb84044fdfda7f2cd5f42453581bc987f.svg" style="height: 54px;" type="image/svg+xml"&gt;\[ss=\int_{-L}^{L}sin\frac{m\pi x}{L}\cdot sin\frac{n\pi x}{L}dx=
\begin{cases}
    L      &amp;amp; m = n \\
    0      &amp;amp; m \neq n
\end{cases}\]&lt;/object&gt;
&lt;p&gt;We can use exactly the same approach to show that:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/bd73561c5868f1519b9b264f81010d9a513dbae6.svg" style="height: 54px;" type="image/svg+xml"&gt;\[cc=\int_{-L}^{L}cos\frac{m\pi x}{L}\cdot cos\frac{n\pi x}{L}dx=
\begin{cases}
    L      &amp;amp; m = n \\
    0      &amp;amp; m \neq n
\end{cases}\]&lt;/object&gt;
&lt;p&gt;One more variant to cover:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/f6b7bc73da6ce073e32f0f1253ab5270d19973c5.svg" style="height: 44px;" type="image/svg+xml"&gt;\[sc=\int_{-L}^{L}sin\frac{m\pi x}{L}\cdot cos\frac{n\pi x}{L}dx\]&lt;/object&gt;
&lt;p&gt;Since sine is an odd function and cosine is an even function, their
product is an odd function. And the integral of an odd function over a
symmetric interval is 0 (see &lt;a class="reference external" href="https://eli.thegreenplace.net/2025/notes-on-even-and-odd-functions/"&gt;this post for more
details&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Therefore:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/8b8669232a6f30dc68a091abffc787858632cb5c.svg" style="height: 44px;" type="image/svg+xml"&gt;\[sc=\int_{-L}^{L}sin\frac{m\pi x}{L}\cdot cos\frac{n\pi x}{L}dx=0\]&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="appendix-c-a-useful-integral"&gt;
&lt;h2&gt;Appendix C: A useful integral&lt;/h2&gt;
&lt;p&gt;Let’s calculate the indefinite integral:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/df863382117243993f6ef34cf6216f181f891d19.svg" style="height: 40px;" type="image/svg+xml"&gt;\[I=\int x\cdot sin(kx) dx\]&lt;/object&gt;
&lt;p&gt;For some constant &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/13fbd79c3d390e5d6585a21e11ff5ec1970cff0c.svg" style="height: 12px;" type="image/svg+xml"&gt;k&lt;/object&gt;. We’ll use integration by parts:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/8033553504b7b9ace816e595172d3942155fa8f1.svg" style="height: 40px;" type="image/svg+xml"&gt;\[\int u\cdot dv =u\cdot v - \int v\cdot du\]&lt;/object&gt;
&lt;p&gt;Here &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/a6327890f9dd75f11f057eb1e4465c365cd3b531.svg" style="height: 8px;" type="image/svg+xml"&gt;u=x&lt;/object&gt;, so &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/febc1f31b2dbfc3e5d91801704e4d37f73c047af.svg" style="height: 12px;" type="image/svg+xml"&gt;du=dx&lt;/object&gt;. Also &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/0a3c6cb92a28005f4435cf19ab35bd121d69cd09.svg" style="height: 19px;" type="image/svg+xml"&gt;dv=sin(kx)&lt;/object&gt;, so
&lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/850143056c00b486079d9e102e7354b38236fbcb.svg" style="height: 25px;" type="image/svg+xml"&gt;v=-\frac{cos(kx)}{k}&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;Putting it together:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/552c213e2d0c70d208bd577d07d4fb37f2d19a0c.svg" style="height: 42px;" type="image/svg+xml"&gt;\[I=\frac{-x\cdot cos(kx)}{k}+\int \frac{cos(kx)}{k} dx=\frac{-x\cdot cos(kx)}{k}+\frac{sin(kx)}{k^2}\]&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="appendix-d-sinusoid-with-phase-as-a-sum-of-sin-and-cos"&gt;
&lt;h2&gt;Appendix D: Sinusoid with phase as a sum of sin and cos&lt;/h2&gt;
&lt;p&gt;Let’s take a general sinusoid with magnitude &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/22ea1c649c82946aa6e479e1ffd321e4a318b1b0.svg" style="height: 12px;" type="image/svg+xml"&gt;q&lt;/object&gt;, frequency
&lt;img alt="w" class="valign-0" src="https://eli.thegreenplace.net/images/math/aff024fe4ab0fece4091de044c58c9ae4233383a.png" style="height: 8px;" /&gt; and phase &lt;img alt="\theta" class="valign-0" src="https://eli.thegreenplace.net/images/math/cb005d76f9f2e394a770c2562c2e150a413b3216.png" style="height: 12px;" /&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/2c7bd5bad4fe6202ce4cdb40050bd68190b3aeb9.svg" style="height: 19px;" type="image/svg+xml"&gt;\[s(x)=q\cdot cos(wx+\theta)\]&lt;/object&gt;
&lt;p&gt;We’re going to show that &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/68cee1190d7058555e058756fed1d6527ab89855.svg" style="height: 19px;" type="image/svg+xml"&gt;s(x)&lt;/object&gt; can be represented as a sum of a
&lt;em&gt;sine&lt;/em&gt; and a &lt;em&gt;cosine&lt;/em&gt; with no phase. This is related to &lt;a class="reference external" href="https://eli.thegreenplace.net/2023/sum-of-same-frequency-sinusoids/"&gt;my earlier post
on the sum of same-frequency
sinusoids&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Let’s start by expanding &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/68cee1190d7058555e058756fed1d6527ab89855.svg" style="height: 19px;" type="image/svg+xml"&gt;s(x)&lt;/object&gt; using a trigonometric identity:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/e8984abab15f66276ebb92fa0d02cfe9eed5c934.svg" style="height: 19px;" type="image/svg+xml"&gt;\[s(x)=q\cdot cos(\theta)cos(wx)-q\cdot sin(\theta)sin(wx)\]&lt;/object&gt;
&lt;p&gt;Now we’ll denote: &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/dcb99eb292280e6a796bbcb514744c3c301f0a35.svg" style="height: 19px;" type="image/svg+xml"&gt;a=q\cdot cos(\theta)&lt;/object&gt; and
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/af9b66bdf49b9575a347a5bf3bb7acfad1ef390b.svg" style="height: 19px;" type="image/svg+xml"&gt;b=-q\cdot sin(\theta)&lt;/object&gt;, so:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/fac6a492043d2c4afd90bf19471756cd0177227e.svg" style="height: 19px;" type="image/svg+xml"&gt;\[s(x)=a\cdot cos(wx)+b\cdot sin(wx)\]&lt;/object&gt;
&lt;p&gt;We have &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8.svg" style="height: 8px;" type="image/svg+xml"&gt;a&lt;/object&gt; and &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98.svg" style="height: 13px;" type="image/svg+xml"&gt;b&lt;/object&gt; in terms of &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/22ea1c649c82946aa6e479e1ffd321e4a318b1b0.svg" style="height: 12px;" type="image/svg+xml"&gt;q&lt;/object&gt; and
&lt;img alt="\theta" class="valign-0" src="https://eli.thegreenplace.net/images/math/cb005d76f9f2e394a770c2562c2e150a413b3216.png" style="height: 12px;" /&gt;, but what about the other way around?&lt;/p&gt;
&lt;p&gt;Let’s take the equations:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/bed3f7ea8728473d264871af14bedc7371943db4.svg" style="height: 46px;" type="image/svg+xml"&gt;\[\begin{aligned}
    a&amp;amp;=q\cdot cos(\theta)\\
    b&amp;amp;=-q\cdot sin(\theta)
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Square both of them and add together:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/ef69aacd4b99f916e773666322d7664a7f80b416.svg" style="height: 52px;" type="image/svg+xml"&gt;\[\begin{aligned}
    a^2+b^2&amp;amp;=q^2\cdot(cos^2(\theta)+sin^2(\theta))=q^2\\
    &amp;amp;\Rightarrow q=\sqrt{a^2+b^2}
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Now we’ll take the equations for &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98.svg" style="height: 13px;" type="image/svg+xml"&gt;b&lt;/object&gt; and &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8.svg" style="height: 8px;" type="image/svg+xml"&gt;a&lt;/object&gt; and divide one
by the other:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/df7db0eac6bb842fe0fd6d76e1cd918a74fce9bb.svg" style="height: 69px;" type="image/svg+xml"&gt;\[\begin{aligned}
    \frac{b}{a}&amp;amp;=\frac{-sin(\theta)}{cos(\theta)}\\
    &amp;amp;\Rightarrow\theta=\operatorname{atan2}(-b,a)
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Where &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Atan2"&gt;the atan2 function&lt;/a&gt; is
careful to take into account the sign of both numerator and denominator.
Also it’s worth mentioning that &lt;img alt="\theta" class="valign-0" src="https://eli.thegreenplace.net/images/math/cb005d76f9f2e394a770c2562c2e150a413b3216.png" style="height: 12px;" /&gt; is determined up to
additions of &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/0833718ca4569f36e84dbdc7742eaec65e49b150.svg" style="height: 12px;" type="image/svg+xml"&gt;2\pi&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;To conclude, for any &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/22ea1c649c82946aa6e479e1ffd321e4a318b1b0.svg" style="height: 12px;" type="image/svg+xml"&gt;q&lt;/object&gt;, &lt;img alt="w" class="valign-0" src="https://eli.thegreenplace.net/images/math/aff024fe4ab0fece4091de044c58c9ae4233383a.png" style="height: 8px;" /&gt; and &lt;img alt="\theta" class="valign-0" src="https://eli.thegreenplace.net/images/math/cb005d76f9f2e394a770c2562c2e150a413b3216.png" style="height: 12px;" /&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/f202b285532ca490fbec00a7a182a3ee518d945f.svg" style="height: 19px;" type="image/svg+xml"&gt;\[q\cdot cos(wx+\theta)=a\cdot cos(wx)+b\cdot sin(wx)\]&lt;/object&gt;
&lt;p&gt;With the aforementioned conversion formulas for &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8.svg" style="height: 8px;" type="image/svg+xml"&gt;a&lt;/object&gt;, &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98.svg" style="height: 13px;" type="image/svg+xml"&gt;b&lt;/object&gt;.&lt;/p&gt;
&lt;hr class="docutils" /&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-1" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-1"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;A function &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt; is called periodic if there exists some
constant &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/cf2af45cefa3d7ceadaff0dfa38db6898e6ff301.svg" style="height: 14px;" type="image/svg+xml"&gt;P&amp;gt;0&lt;/object&gt; such that &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/02c74bd56236fce328ac0a48fda293dca178af78.svg" style="height: 19px;" type="image/svg+xml"&gt;f(x+P)=f(x)\ \forall x&lt;/object&gt;. In our
case, we denote the period as &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/f200dcf24d7a0a3035a4c7023b03459f6b22e3cc.svg" style="height: 12px;" type="image/svg+xml"&gt;P=2L&lt;/object&gt; to make presentation and
calculations neater.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-2" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-2"&gt;[2]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Since &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/9ea1a3c68ad2e5a68e78cff7fe65bf38d08519bb.svg" style="height: 20px;" type="image/svg+xml"&gt;f(x)\in L^2&lt;/object&gt;, we know that it’s integrable on a finite
interval&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-3" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-3"&gt;[3]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;There’s also an infinite number of less natural ways to extend the
function; they will still work, but may make the calculation
needlessly complicated&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-4" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-4"&gt;[4]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;I chose this one because the more common ones like a square wave and
a sawtooth wave have many derivations available online, including on
Wikipedia.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-5" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-5"&gt;[5]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Try it for yourself - it’s a good exercise.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-6" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-6"&gt;[6]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;When &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/7cf469bc52df59c26bf99dd9ecbf71b7f6f5ab78.svg" style="height: 16px;" type="image/svg+xml"&gt;q_n=0&lt;/object&gt; for some &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt;, the corresponding
&lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/7dde5e64e049b615293b3dd8f94a70defa6a789b.svg" style="height: 15px;" type="image/svg+xml"&gt;\theta_n&lt;/object&gt; can be chosen arbitrarily.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-7" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-7"&gt;[7]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;For a complex-valued &lt;img alt="f(x)" class="valign-m4" src="https://eli.thegreenplace.net/images/math/3e03f4706048fbc6c5a252a85d066adf107fcc1f.png" style="height: 18px;" /&gt;, this conjugate symmetry no longer
holds in general. &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/278ab95d3a54aae8eaa25c34af66d93a19b5e75f.svg" style="height: 11px;" type="image/svg+xml"&gt;a_n&lt;/object&gt; and &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/54d608cbef1529c3089b9281aa6dcb16a2e65f1f.svg" style="height: 15px;" type="image/svg+xml"&gt;b_n&lt;/object&gt; may be complex, so
&lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/e6456786af3c999a8eda7658e37f7bf5d1bb0db0.svg" style="height: 15px;" type="image/svg+xml"&gt;C_n&lt;/object&gt; and &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/bdd14e4abf9623d7582bf4f5ba37adc1b564491f.svg" style="height: 15px;" type="image/svg+xml"&gt;C_{-n}&lt;/object&gt; need not be conjugates.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;script src="https://eli.thegreenplace.net/demos/fourier/fourier-plot.js"&gt;
&lt;/script&gt;&lt;/div&gt;
</content><category term="misc"></category><category term="Math"></category></entry><entry><title>Scaling, stretching and shifting sinusoids</title><link href="https://eli.thegreenplace.net/2026/scaling-stretching-and-shifting-sinusoids/" rel="alternate"></link><published>2026-05-02T07:17:00-07:00</published><updated>2026-05-02T14:18:12-07:00</updated><author><name>Eli Bendersky</name></author><id>tag:eli.thegreenplace.net,2026-05-02:/2026/scaling-stretching-and-shifting-sinusoids/</id><summary type="html">&lt;p&gt;This is a brief and simple &lt;a class="footnote-reference" href="#footnote-1" id="footnote-reference-1"&gt;[1]&lt;/a&gt; explanation of how to adjust the
standard sinusoid &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/1f2ea8ffab8deb0e5b854a260a68b42b7eb7b048.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(x)&lt;/object&gt; to change its amplitude, frequency and
phase shift. More precisely, given the general function:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/85a45cfe4c1671765c3ab7e3949d8f74f780a0f3.svg" style="height: 19px;" type="image/svg+xml"&gt;\[s(x)=A\cdot sin(w\cdot x+\theta)\]&lt;/object&gt;
&lt;p&gt;We’ll see how adjusting the parameters &lt;img alt="A" class="valign-0" src="https://eli.thegreenplace.net/images/math/6dcd4ce23d88e2ee9568ba546c007c63d9131c1b.png" style="height: 12px;" /&gt;, &lt;img alt="w" class="valign-0" src="https://eli.thegreenplace.net/images/math/aff024fe4ab0fece4091de044c58c9ae4233383a.png" style="height: 8px;" /&gt; and
&lt;img alt="\theta" class="valign-0" src="https://eli.thegreenplace.net/images/math/cb005d76f9f2e394a770c2562c2e150a413b3216.png" style="height: 12px;" /&gt; affect the …&lt;/p&gt;</summary><content type="html">&lt;p&gt;This is a brief and simple &lt;a class="footnote-reference" href="#footnote-1" id="footnote-reference-1"&gt;[1]&lt;/a&gt; explanation of how to adjust the
standard sinusoid &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/1f2ea8ffab8deb0e5b854a260a68b42b7eb7b048.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(x)&lt;/object&gt; to change its amplitude, frequency and
phase shift. More precisely, given the general function:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/85a45cfe4c1671765c3ab7e3949d8f74f780a0f3.svg" style="height: 19px;" type="image/svg+xml"&gt;\[s(x)=A\cdot sin(w\cdot x+\theta)\]&lt;/object&gt;
&lt;p&gt;We’ll see how adjusting the parameters &lt;img alt="A" class="valign-0" src="https://eli.thegreenplace.net/images/math/6dcd4ce23d88e2ee9568ba546c007c63d9131c1b.png" style="height: 12px;" /&gt;, &lt;img alt="w" class="valign-0" src="https://eli.thegreenplace.net/images/math/aff024fe4ab0fece4091de044c58c9ae4233383a.png" style="height: 8px;" /&gt; and
&lt;img alt="\theta" class="valign-0" src="https://eli.thegreenplace.net/images/math/cb005d76f9f2e394a770c2562c2e150a413b3216.png" style="height: 12px;" /&gt; affect the shape of &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/68cee1190d7058555e058756fed1d6527ab89855.svg" style="height: 19px;" type="image/svg+xml"&gt;s(x)&lt;/object&gt;. Each section below
covers one of these aspects mathematically, and you can use the demo at
the bottom to experiment with the topic visually.&lt;/p&gt;
&lt;div class="section" id="scaling"&gt;
&lt;h2&gt;Scaling&lt;/h2&gt;
&lt;p&gt;Scaling is conceptually the simplest change; we adjust &lt;img alt="A" class="valign-0" src="https://eli.thegreenplace.net/images/math/6dcd4ce23d88e2ee9568ba546c007c63d9131c1b.png" style="height: 12px;" /&gt; to
increase or decrease the amplitude (maximal height) of &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/68cee1190d7058555e058756fed1d6527ab89855.svg" style="height: 19px;" type="image/svg+xml"&gt;s(x)&lt;/object&gt;. Setting
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/6a6272d9558de919b19aa13d56dc37e11c358150.svg" style="height: 13px;" type="image/svg+xml"&gt;A=2&lt;/object&gt; will make the &lt;img alt="y" class="valign-m4" src="https://eli.thegreenplace.net/images/math/95cb0bfd2977c761298d9624e4b4d4c72a39974a.png" style="height: 12px;" /&gt; value twice as large (in both the positive
and negative direction) as the original function.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="stretching"&gt;
&lt;h2&gt;Stretching&lt;/h2&gt;
&lt;p&gt;Stretching changes the frequency of &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/1f2ea8ffab8deb0e5b854a260a68b42b7eb7b048.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(x)&lt;/object&gt;, which is inverse
proportional to its period. The baseline function &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/1f2ea8ffab8deb0e5b854a260a68b42b7eb7b048.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(x)&lt;/object&gt; has a
period of &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/0833718ca4569f36e84dbdc7742eaec65e49b150.svg" style="height: 12px;" type="image/svg+xml"&gt;2\pi&lt;/object&gt;, meaning it repeats every &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/0833718ca4569f36e84dbdc7742eaec65e49b150.svg" style="height: 12px;" type="image/svg+xml"&gt;2\pi&lt;/object&gt;. In other
words, &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/48691bfc145b339ef1a94cfac6b43af86264c14b.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(x)=sin(x+2\pi)&lt;/object&gt; for any &lt;img alt="x" class="valign-0" src="https://eli.thegreenplace.net/images/math/11f6ad8ec52a2984abaafd7c3b516503785c2072.png" style="height: 8px;" /&gt;.&lt;/p&gt;
&lt;p&gt;If we set &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/c8cb42808e0de9f61517078296f19134ac680422.svg" style="height: 12px;" type="image/svg+xml"&gt;w=2&lt;/object&gt;, we get &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/fd197962a5779ba863ea0db91d1ee9210d07002a.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(2x)&lt;/object&gt;. This function repeats
itself twice as fast as &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/1f2ea8ffab8deb0e5b854a260a68b42b7eb7b048.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(x)&lt;/object&gt;, because &lt;img alt="x" class="valign-0" src="https://eli.thegreenplace.net/images/math/11f6ad8ec52a2984abaafd7c3b516503785c2072.png" style="height: 8px;" /&gt; is multiplied
by 2 before being fed into the sinusoid. If &lt;img alt="x" class="valign-0" src="https://eli.thegreenplace.net/images/math/11f6ad8ec52a2984abaafd7c3b516503785c2072.png" style="height: 8px;" /&gt; changes by
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/6ac47b6d7372b4087583cfd048d20f4c1571f5cf.svg" style="height: 8px;" type="image/svg+xml"&gt;\pi&lt;/object&gt;, the sinusoid’s input changes by &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/0833718ca4569f36e84dbdc7742eaec65e49b150.svg" style="height: 12px;" type="image/svg+xml"&gt;2\pi&lt;/object&gt;.
Therefore, the period of &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/fd197962a5779ba863ea0db91d1ee9210d07002a.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(2x)&lt;/object&gt; is &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/6ac47b6d7372b4087583cfd048d20f4c1571f5cf.svg" style="height: 8px;" type="image/svg+xml"&gt;\pi&lt;/object&gt;, the period of
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/fd718cb7cfa198e46efa9f40dda81c2fb2aa26c9.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(4x)&lt;/object&gt; is &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/7813100388622a69c767d297b453832a9df166fb.svg" style="height: 19px;" type="image/svg+xml"&gt;\frac{\pi}{2}&lt;/object&gt; and so on. &lt;a class="footnote-reference" href="#footnote-2" id="footnote-reference-2"&gt;[2]&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;More generally, the period of &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/59349af0e0016059129f0961133daaa009e68aa1.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(wx)&lt;/object&gt; is &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/af5a5e1f3222c095bbceea6c7cf5e6685bdc0ce5.svg" style="height: 22px;" type="image/svg+xml"&gt;\frac{2\pi}{w}&lt;/object&gt;.
Play with the demo below to see this in action, by changing &lt;img alt="w" class="valign-0" src="https://eli.thegreenplace.net/images/math/aff024fe4ab0fece4091de044c58c9ae4233383a.png" style="height: 8px;" /&gt;
and observing how the waveform changes.&lt;/p&gt;
&lt;p&gt;If we know the period &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/516b9783fca517eecbd1d064da2d165310b19759.svg" style="height: 12px;" type="image/svg+xml"&gt;p&lt;/object&gt; we want, we can easily calculate the
&lt;img alt="w" class="valign-0" src="https://eli.thegreenplace.net/images/math/aff024fe4ab0fece4091de044c58c9ae4233383a.png" style="height: 8px;" /&gt; that gives us this period:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/1e0b7e1350f41a5d194ed4596e24ba19298728ff.svg" style="height: 40px;" type="image/svg+xml"&gt;\[p=\frac{2\pi}{w} \implies w=\frac{2\pi}{p}\]&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="shifting"&gt;
&lt;h2&gt;Shifting&lt;/h2&gt;
&lt;p&gt;The final parameter we discuss is &lt;img alt="\theta" class="valign-0" src="https://eli.thegreenplace.net/images/math/cb005d76f9f2e394a770c2562c2e150a413b3216.png" style="height: 12px;" /&gt;; it’s called the
&lt;em&gt;phase&lt;/em&gt; of the sinusoid. In the baseline &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/1f2ea8ffab8deb0e5b854a260a68b42b7eb7b048.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(x)&lt;/object&gt;,
&lt;img alt="\theta=0" class="valign-0" src="https://eli.thegreenplace.net/images/math/a1dffbe89f1ec5a919198de979fca459eb7fdf84.png" style="height: 12px;" /&gt;. The sinusoid is 0 at &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/8bdf21367eee06097384c37b0448375f07f950f0.svg" style="height: 12px;" type="image/svg+xml"&gt;x=0&lt;/object&gt;, achieves its
positive peak at &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/45cd304b3c843af35927b7c0245ea384eb910e58.svg" style="height: 19px;" type="image/svg+xml"&gt;x=\frac{\pi}{2}&lt;/object&gt;, crosses 0 again at
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/772d339297416ff00b9b1bb9e94d4967ed2cd240.svg" style="height: 8px;" type="image/svg+xml"&gt;x=\pi&lt;/object&gt;, negative peak at &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/93bdc56d302f94f04eabe5a5613f247ae868be72.svg" style="height: 22px;" type="image/svg+xml"&gt;x=\frac{3\pi}{2}&lt;/object&gt; and returns to
its original position at &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/c40e087d3c6af21cd2ddb732737bcab6381f1feb.svg" style="height: 12px;" type="image/svg+xml"&gt;x=2\pi&lt;/object&gt; where the repetition begins.&lt;/p&gt;
&lt;p&gt;By adding a non-zero &lt;img alt="\theta" class="valign-0" src="https://eli.thegreenplace.net/images/math/cb005d76f9f2e394a770c2562c2e150a413b3216.png" style="height: 12px;" /&gt;, we don’t affect the sinusoid’s
amplitude or frequency, but we do shift it right or left along the
&lt;img alt="x" class="valign-0" src="https://eli.thegreenplace.net/images/math/11f6ad8ec52a2984abaafd7c3b516503785c2072.png" style="height: 8px;" /&gt; axis. For example, suppose we use the function
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/f07cc6da4bbe7259442b8c4dc6f9bdaaa2c2933c.svg" style="height: 19px;" type="image/svg+xml"&gt;sin(x+\theta)&lt;/object&gt; with &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/0debc99bd20cf70823ed08246f837595d0cde3bf.svg" style="height: 19px;" type="image/svg+xml"&gt;\theta=\frac{\pi}{2}&lt;/object&gt;. Then when
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/8bdf21367eee06097384c37b0448375f07f950f0.svg" style="height: 12px;" type="image/svg+xml"&gt;x=0&lt;/object&gt;, we have &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/f04381be541e525ad448580297568f9bf94dbc5d.svg" style="height: 20px;" type="image/svg+xml"&gt;sin(\frac{\pi}{2})&lt;/object&gt;, so the sinusoid is
already at its positive peak; at &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/45cd304b3c843af35927b7c0245ea384eb910e58.svg" style="height: 19px;" type="image/svg+xml"&gt;x=\frac{\pi}{2}&lt;/object&gt;, the sinusoid
crosses 0 into the negatives, etc. Everything happens earlier (by
exactly the value of &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/0debc99bd20cf70823ed08246f837595d0cde3bf.svg" style="height: 19px;" type="image/svg+xml"&gt;\theta=\frac{\pi}{2}&lt;/object&gt;) than in the baseline
sinusoid. In other words, we’ve shifted the function &lt;em&gt;left&lt;/em&gt; by
&lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/7813100388622a69c767d297b453832a9df166fb.svg" style="height: 19px;" type="image/svg+xml"&gt;\frac{\pi}{2}&lt;/object&gt;. Similarly, when &lt;img alt="\theta" class="valign-0" src="https://eli.thegreenplace.net/images/math/cb005d76f9f2e394a770c2562c2e150a413b3216.png" style="height: 12px;" /&gt; is negative,
everything happens later, and the function is shifted &lt;em&gt;right&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="putting-it-all-together"&gt;
&lt;h2&gt;Putting it all together&lt;/h2&gt;
&lt;p&gt;We’ve now gone over all the parameters for the function:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/85a45cfe4c1671765c3ab7e3949d8f74f780a0f3.svg" style="height: 19px;" type="image/svg+xml"&gt;\[s(x)=A\cdot sin(w\cdot x+\theta)\]&lt;/object&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;img alt="A" class="valign-0" src="https://eli.thegreenplace.net/images/math/6dcd4ce23d88e2ee9568ba546c007c63d9131c1b.png" style="height: 12px;" /&gt; controls the scaling factor (amplitude).&lt;/li&gt;
&lt;li&gt;&lt;img alt="w" class="valign-0" src="https://eli.thegreenplace.net/images/math/aff024fe4ab0fece4091de044c58c9ae4233383a.png" style="height: 8px;" /&gt; is the frequency and controls the repetition period&lt;/li&gt;
&lt;li&gt;&lt;img alt="\theta" class="valign-0" src="https://eli.thegreenplace.net/images/math/cb005d76f9f2e394a770c2562c2e150a413b3216.png" style="height: 12px;" /&gt; controls the phase - how much the sinusoid is shifted
left or right&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Use the demo below to adjust these parameters and observe their effect on
the sinusoid:&lt;/p&gt;
&lt;link rel="stylesheet" href="https://eli.thegreenplace.net/demos/sinus/sinus-demo.css"&gt;

&lt;!-- Canvas shows the current graph and legend;
     controls below provide the parameter inputs. --&gt;
&lt;div class="sinus-demo-wrap"&gt;
  &lt;canvas id="sinus-demo-canvas" class="sinus-demo-canvas" width="760" height="390"&gt;
  Your browser does not support the HTML5 canvas tag.
  &lt;/canvas&gt;

  &lt;div class="sinus-demo-controls"&gt;
    &lt;div class="sinus-demo-grid"&gt;
      &lt;label class="sinus-demo-label" for="sinus-demo-amp"&gt;
        A
        &lt;input id="sinus-demo-amp" class="sinus-demo-input" type="number" value="1" step="0.1"&gt;
      &lt;/label&gt;

      &lt;label class="sinus-demo-label" for="sinus-demo-omega"&gt;
        ω
        &lt;input id="sinus-demo-omega" class="sinus-demo-input" type="number" value="1" step="0.1"&gt;
      &lt;/label&gt;

      &lt;label class="sinus-demo-label" for="sinus-demo-theta"&gt;
        θ
        &lt;input id="sinus-demo-theta" class="sinus-demo-input" type="number" value="0" step="0.1"&gt;
      &lt;/label&gt;
    &lt;/div&gt;

    &lt;div id="sinus-demo-message" class="sinus-demo-message"&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;script src="https://eli.thegreenplace.net/demos/sinus/sinus-demo.js"&gt;
&lt;/script&gt;&lt;hr class="docutils" /&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-1" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-1"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;The math level of this post is high-school, at best. My main goal
here is to test how to integrate interactive demos into my blog
posts.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-2" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-2"&gt;[2]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;This can be a bit counter-intuitive at first; we scale &lt;img alt="w" class="valign-0" src="https://eli.thegreenplace.net/images/math/aff024fe4ab0fece4091de044c58c9ae4233383a.png" style="height: 8px;" /&gt; by
2, but the period scales by half. Why? The reason is that &lt;img alt="w" class="valign-0" src="https://eli.thegreenplace.net/images/math/aff024fe4ab0fece4091de044c58c9ae4233383a.png" style="height: 8px;" /&gt;
affects the sinusoid’s &lt;em&gt;domain&lt;/em&gt;, while the period is a property of
its &lt;em&gt;range&lt;/em&gt;. Therefore, an inverse relation is reasonable, once we
put more thought into it. In fact, &lt;img alt="w" class="valign-0" src="https://eli.thegreenplace.net/images/math/aff024fe4ab0fece4091de044c58c9ae4233383a.png" style="height: 8px;" /&gt; is often called the
&lt;em&gt;angular frequency&lt;/em&gt; of the sinusoid, and frequency is inverse
proportional to the period.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
</content><category term="misc"></category><category term="Math"></category></entry><entry><title>Notes on Lagrange Interpolating Polynomials</title><link href="https://eli.thegreenplace.net/2026/notes-on-lagrange-interpolating-polynomials/" rel="alternate"></link><published>2026-02-28T18:58:00-08:00</published><updated>2026-03-05T13:31:03-08:00</updated><author><name>Eli Bendersky</name></author><id>tag:eli.thegreenplace.net,2026-02-28:/2026/notes-on-lagrange-interpolating-polynomials/</id><summary type="html">&lt;p&gt;&lt;em&gt;Polynomial interpolation&lt;/em&gt; is a method of finding a polynomial function
that fits a given set of data perfectly. More concretely, suppose we
have a set of &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; distinct points &lt;a class="footnote-reference" href="#footnote-1" id="footnote-reference-1"&gt;[1]&lt;/a&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/e3ee741ff781bf26237c69b505322eb378075e89.svg" style="height: 19px;" type="image/svg+xml"&gt;\[(x_0,y_0), (x_1, y_1), (x_2, y_2)\cdots(x_n, y_n)\]&lt;/object&gt;
&lt;p&gt;And we want to find the polynomial coefficients &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/3cb777352d19998f6099864dfe85849e46fd0d8c.svg" style="height: 11px;" type="image/svg+xml"&gt;{a_0\cdots …&lt;/object&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;em&gt;Polynomial interpolation&lt;/em&gt; is a method of finding a polynomial function
that fits a given set of data perfectly. More concretely, suppose we
have a set of &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; distinct points &lt;a class="footnote-reference" href="#footnote-1" id="footnote-reference-1"&gt;[1]&lt;/a&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/e3ee741ff781bf26237c69b505322eb378075e89.svg" style="height: 19px;" type="image/svg+xml"&gt;\[(x_0,y_0), (x_1, y_1), (x_2, y_2)\cdots(x_n, y_n)\]&lt;/object&gt;
&lt;p&gt;And we want to find the polynomial coefficients &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/3cb777352d19998f6099864dfe85849e46fd0d8c.svg" style="height: 11px;" type="image/svg+xml"&gt;{a_0\cdots a_n}&lt;/object&gt;
such that:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/4aff81770a1cc10239926be6d6676eb37fba719d.svg" style="height: 22px;" type="image/svg+xml"&gt;\[p(x)=a_0 + a_1 x + a_2 x^2 + \cdots + a_n x^n\]&lt;/object&gt;
&lt;p&gt;Fits all our points; that is &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/9bee0b2482233e55d638019ff5324f45ce5c0134.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x_0)=y_0&lt;/object&gt;, &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/1066a27080e8f4f98e1e837c563063ce09929300.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x_1)=y_1&lt;/object&gt; etc.&lt;/p&gt;
&lt;p&gt;This post discusses a common approach to solving this problem, and also
shows why such a polynomial exists and is unique.&lt;/p&gt;
&lt;div class="section" id="showing-existence-using-linear-algebra"&gt;
&lt;h2&gt;Showing existence using linear algebra&lt;/h2&gt;
&lt;p&gt;When we assign all points &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/fac14e12be52903f4008e439178230b3eefb437a.svg" style="height: 19px;" type="image/svg+xml"&gt;(x_i, y_i)&lt;/object&gt; into the generic polynomial
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt;, we get:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/708bd02c5cc4f2ddb0dbc93967053e55853683d3.svg" style="height: 134px;" type="image/svg+xml"&gt;\[\begin{aligned}
p(x_0)&amp;amp;=a_0 + a_1 x_0 + a_2 x_0^2 + \cdots a_n x_0^n = y_0\\
p(x_1)&amp;amp;=a_0 + a_1 x_1 + a_2 x_1^2 + \cdots a_n x_1^n = y_1\\
p(x_2)&amp;amp;=a_0 + a_1 x_2 + a_2 x_2^2 + \cdots a_n x_2^n = y_2\\
\cdots \\
p(x_n)&amp;amp;=a_0 + a_1 x_n + a_2 x_n^2 + \cdots a_n x_n^n = y_n\\
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;We want to solve for the coefficients &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/1ba9b59bdee92f38c1698c784b67ba70f803331d.svg" style="height: 11px;" type="image/svg+xml"&gt;a_i&lt;/object&gt;. This is a linear
system of equations that can be represented by the following matrix
equation:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/4352a3b8e07b33cc419089f1c48e0b360c9200e5.svg" style="height: 159px;" type="image/svg+xml"&gt;\[{\renewcommand{\arraystretch}{1.5}\begin{bmatrix}
     1 &amp;amp; x_0 &amp;amp; x_0^2 &amp;amp; \dots &amp;amp; x_0^n\\
     1 &amp;amp; x_1 &amp;amp; x_1^2 &amp;amp; \dots &amp;amp; x_1^n\\
     1 &amp;amp; x_2 &amp;amp; x_2^2 &amp;amp; \dots &amp;amp; x_2^n\\
     \vdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp;\vdots \\
     1 &amp;amp; x_n &amp;amp; x_n^2 &amp;amp; \dots &amp;amp; x_n^n
 \end{bmatrix}
 \begin{bmatrix}
     a_0\\
     a_1\\
     a_2\\
     \vdots\\
     a_n\\
 \end{bmatrix}=
 \begin{bmatrix}
     y_0\\
     y_1\\
     y_2\\
     \vdots\\
     y_n\\
 \end{bmatrix}
 }\]&lt;/object&gt;
&lt;p&gt;The matrix on the left is called the &lt;em&gt;Vandermonde matrix&lt;/em&gt;. This matrix
is known to be invertible (see Appendix for a proof); therefore, this
system of equations has a single solution that can be calculated by
inverting the matrix.&lt;/p&gt;
&lt;p&gt;In practice, however, the Vandermonde matrix is often numerically
ill-conditioned, so inverting it isn’t the best way to calculate exact
polynomial coefficients. Several better methods exist.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="lagrange-polynomial"&gt;
&lt;h2&gt;Lagrange Polynomial&lt;/h2&gt;
&lt;p&gt;Lagrange interpolation polynomials emerge from a simple, yet powerful
idea. Let’s define the &lt;em&gt;Lagrange basis&lt;/em&gt; functions &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt;
(&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/71047ffb369f30ea7df6aad7d69de2edc1eca912.svg" style="height: 18px;" type="image/svg+xml"&gt;i \in [0, n]&lt;/object&gt;) as follows, given our points &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/fac14e12be52903f4008e439178230b3eefb437a.svg" style="height: 19px;" type="image/svg+xml"&gt;(x_i, y_i)&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/5e4d0981c95e59436de02cb6fc85dcdcf4537f1b.svg" style="height: 54px;" type="image/svg+xml"&gt;\[l_i(x) =
\begin{cases}
    1      &amp;amp; x = x_i \\
    0      &amp;amp; x = x_j \quad \forall j \neq i
\end{cases}\]&lt;/object&gt;
&lt;p&gt;In words, &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt; is constrained to 1 at &lt;img alt="x_i" class="valign-m3" src="https://eli.thegreenplace.net/images/math/34e03e6559b14df9fe5a97bbd2ed10109dfebbd3.png" style="height: 11px;" /&gt; and to 0 at
all other &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/73058e43db0f4edc791b10f27f913cbc5d361ab6.svg" style="height: 14px;" type="image/svg+xml"&gt;x_j&lt;/object&gt;. We don’t care about its value at any other point.&lt;/p&gt;
&lt;p&gt;The linear combination:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/9e02d7ad79abe9dd4e108d6e33e02bd6b2cece5e.svg" style="height: 49px;" type="image/svg+xml"&gt;\[p(x)=\sum_{i=0}^{n}y_i l_i(x)\]&lt;/object&gt;
&lt;p&gt;is then a valid interpolating polynomial for our set of &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt;
points, because it’s equal to &lt;img alt="y_i" class="valign-m4" src="https://eli.thegreenplace.net/images/math/35c2ac2f82d0ff8f9011b596ed7e54bfcc55f471.png" style="height: 12px;" /&gt; at each &lt;img alt="x_i" class="valign-m3" src="https://eli.thegreenplace.net/images/math/34e03e6559b14df9fe5a97bbd2ed10109dfebbd3.png" style="height: 11px;" /&gt; (take a
moment to convince yourself this is true).&lt;/p&gt;
&lt;p&gt;How do we find &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt;? The key insight comes from studying the
following function:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/ab2f106bd0be79644b4f08e7241d53541fde914c.svg" style="height: 54px;" type="image/svg+xml"&gt;\[l&amp;#x27;_i(x)=(x-x_0)\cdot (x-x_1)\cdots (x-x_{i-1}) \cdot (x-x_{i+1})\cdots (x-x_n)=
\prod_{\substack{0\leq j \leq n \\ j \neq i}}(x-x_j)\]&lt;/object&gt;
&lt;p&gt;This function has &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt; terms &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/ee95074369b77b297d18a5d2500b53463aaf275a.svg" style="height: 20px;" type="image/svg+xml"&gt;(x-x_j)&lt;/object&gt; for all
&lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/6e1be82fe5bc74efdbe2bd9234f5da2cec90f954.svg" style="height: 17px;" type="image/svg+xml"&gt;j\neq i&lt;/object&gt;. It should be easy to see that &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/f2445af2b56e69160a5ee45a30d1a96a97ea8496.svg" style="height: 19px;" type="image/svg+xml"&gt;l&amp;#x27;_i(x)&lt;/object&gt; is 0 at
all &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/73058e43db0f4edc791b10f27f913cbc5d361ab6.svg" style="height: 14px;" type="image/svg+xml"&gt;x_j&lt;/object&gt; when &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/6e1be82fe5bc74efdbe2bd9234f5da2cec90f954.svg" style="height: 17px;" type="image/svg+xml"&gt;j\neq i&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;What about its value at &lt;img alt="x_i" class="valign-m3" src="https://eli.thegreenplace.net/images/math/34e03e6559b14df9fe5a97bbd2ed10109dfebbd3.png" style="height: 11px;" /&gt;, though? We can just assign
&lt;img alt="x_i" class="valign-m3" src="https://eli.thegreenplace.net/images/math/34e03e6559b14df9fe5a97bbd2ed10109dfebbd3.png" style="height: 11px;" /&gt; into &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/f2445af2b56e69160a5ee45a30d1a96a97ea8496.svg" style="height: 19px;" type="image/svg+xml"&gt;l&amp;#x27;_i(x)&lt;/object&gt; to get:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/c4a71af1b8a616db5347164e5abc488dc888da60.svg" style="height: 54px;" type="image/svg+xml"&gt;\[l&amp;#x27;_i(x_i)=\prod_{\substack{0\leq j \leq n \\ j \neq i}}(x_i-x_j)\]&lt;/object&gt;
&lt;p&gt;And then normalize &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/f2445af2b56e69160a5ee45a30d1a96a97ea8496.svg" style="height: 19px;" type="image/svg+xml"&gt;l&amp;#x27;_i(x)&lt;/object&gt;, dividing it by this (constant) value. We get
the Lagrange basis function &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/9556fe744ec99f27b47d421edd5e625e072145b5.svg" style="height: 64px;" type="image/svg+xml"&gt;\[l_i(x)=\frac{l&amp;#x27;_i(x)}{l&amp;#x27;_i(x_i)}=\prod_{\substack{0\leq j \leq n \\ j \neq i}}\frac{x-x_j}{x_i-x_j}\]&lt;/object&gt;
&lt;p&gt;Let’s use a concrete example to visualize this. Suppose we have the
following set of points we want to interpolate:
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/eb71287f6f652c4e2753483486714619516e0822.svg" style="height: 19px;" type="image/svg+xml"&gt;(1,4), (2,2), (3,3)&lt;/object&gt;. We can calculate &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/efa94b9705d7324c446e2fd3a0f87163cf4a09aa.svg" style="height: 19px;" type="image/svg+xml"&gt;l&amp;#x27;_0(x)&lt;/object&gt;,
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/35fec30e61d70678416c62035d3dce29fd3ffc5a.svg" style="height: 19px;" type="image/svg+xml"&gt;l&amp;#x27;_1(x)&lt;/object&gt; and &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/5d4342750343edd5a8607e54a1f6dac771110497.svg" style="height: 19px;" type="image/svg+xml"&gt;l&amp;#x27;_2(x)&lt;/object&gt;, and get the following:&lt;/p&gt;
&lt;img alt="Un-normalized lagrange basis functions for our sample" class="align-center" src="https://eli.thegreenplace.net/images/2026/lagrange-basis.png" /&gt;
&lt;p&gt;Note where each &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/f2445af2b56e69160a5ee45a30d1a96a97ea8496.svg" style="height: 19px;" type="image/svg+xml"&gt;l&amp;#x27;_i(x)&lt;/object&gt; intersects the &lt;img alt="x" class="valign-0" src="https://eli.thegreenplace.net/images/math/11f6ad8ec52a2984abaafd7c3b516503785c2072.png" style="height: 8px;" /&gt; axis. These
functions have the right values at all &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/3430b1a7366e85d75a89e8ef95fffaa8e0fd36f2.svg" style="height: 14px;" type="image/svg+xml"&gt;x_{j\neq i}&lt;/object&gt;. If we
normalize them to obtain &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt;, we get these functions:&lt;/p&gt;
&lt;img alt="Normalized lagrange basis functions for our sample" class="align-center" src="https://eli.thegreenplace.net/images/2026/lagrange-basis-normalized.png" /&gt;
&lt;p&gt;Note that each polynomial is 1 at the appropriate &lt;img alt="x_i" class="valign-m3" src="https://eli.thegreenplace.net/images/math/34e03e6559b14df9fe5a97bbd2ed10109dfebbd3.png" style="height: 11px;" /&gt; and 0 at
all the other &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/3430b1a7366e85d75a89e8ef95fffaa8e0fd36f2.svg" style="height: 14px;" type="image/svg+xml"&gt;x_{j\neq i}&lt;/object&gt;, as required.&lt;/p&gt;
&lt;p&gt;With these &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt;, we can now plot the interpolating polynomial
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/bc2c6fb1897affc253cf6db77c4f7d4a41a5be32.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)=\sum_{i=0}^{n}y_i l_i(x)&lt;/object&gt;, which fits our set of input points:&lt;/p&gt;
&lt;img alt="Interpolation polynomial" class="align-center" src="https://eli.thegreenplace.net/images/2026/lagrange-inter-poly.png" /&gt;
&lt;/div&gt;
&lt;div class="section" id="polynomial-degree-and-uniqueness"&gt;
&lt;h2&gt;Polynomial degree and uniqueness&lt;/h2&gt;
&lt;p&gt;We’ve just seen that the linear combination of Lagrange basis functions:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/9e02d7ad79abe9dd4e108d6e33e02bd6b2cece5e.svg" style="height: 49px;" type="image/svg+xml"&gt;\[p(x)=\sum_{i=0}^{n}y_i l_i(x)\]&lt;/object&gt;
&lt;p&gt;is a valid interpolating polynomial for a set of &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; distinct
points &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/fac14e12be52903f4008e439178230b3eefb437a.svg" style="height: 19px;" type="image/svg+xml"&gt;(x_i, y_i)&lt;/object&gt;. What is its degree?&lt;/p&gt;
&lt;p&gt;Since the degree of each &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt; is &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt;, then the degree of
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt; is &lt;em&gt;at most&lt;/em&gt; &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt;. We’ve just derived the first part
of the &lt;em&gt;Polynomial interpolation theorem&lt;/em&gt;:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Polynomial interpolation theorem&lt;/strong&gt;: for any &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; data points
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/3e2e9500dcfffb808ec380f67db20f6f0804211e.svg" style="height: 20px;" type="image/svg+xml"&gt;(x_0,y_0), (x_1, y_1)\cdots(x_n, y_n) \in \mathbb{R}^2&lt;/object&gt; where no
two &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/73058e43db0f4edc791b10f27f913cbc5d361ab6.svg" style="height: 14px;" type="image/svg+xml"&gt;x_j&lt;/object&gt; are the same, there exists a unique polynomial
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt; of degree at most &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt; that interpolates these points.&lt;/p&gt;
&lt;p&gt;We’ve demonstrated existence and degree, but not yet &lt;em&gt;uniqueness&lt;/em&gt;. So
let’s turn to that.&lt;/p&gt;
&lt;p&gt;We know that &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt; interpolates all &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; points, and its
degree is &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt;. Suppose there’s another such polynomial
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/90425caaec1646540a7a9049146bf2606d9dbd0d.svg" style="height: 19px;" type="image/svg+xml"&gt;q(x)&lt;/object&gt;. Let’s construct:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/c77eca4deaf27dd00a5908a71840f50160ff7b4e.svg" style="height: 19px;" type="image/svg+xml"&gt;\[r(x)=p(x)-q(x)\]&lt;/object&gt;
&lt;p&gt;That do we know about &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/9468a2656a6201bfa194ec81fb0f78352c9666c9.svg" style="height: 19px;" type="image/svg+xml"&gt;r(x)&lt;/object&gt;? First of all, its value is 0 at all
our &lt;img alt="x_i" class="valign-m3" src="https://eli.thegreenplace.net/images/math/34e03e6559b14df9fe5a97bbd2ed10109dfebbd3.png" style="height: 11px;" /&gt;, so it has &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; &lt;em&gt;roots&lt;/em&gt;. Second, we also know
that its degree is at most &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt; (because it’s the difference of two
polynomials of such degree). These two facts are a contradiction.
No non-zero polynomial of degree &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/189de1175926fa11245f32e4d48aa2a7ab2435b4.svg" style="height: 15px;" type="image/svg+xml"&gt;\leq n&lt;/object&gt; can have
&lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; roots (a basic algebraic fact related to the &lt;em&gt;Fundamental
theorem of algebra&lt;/em&gt;). So &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/9468a2656a6201bfa194ec81fb0f78352c9666c9.svg" style="height: 19px;" type="image/svg+xml"&gt;r(x)&lt;/object&gt; must be the zero polynomial; in
other words, our &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt; is unique &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/4a4e9e431da45a27bc880a8a1ca44d8b1b9bc143.svg" style="height: 12px;" type="image/svg+xml"&gt;\blacksquare&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;Note the implication of uniqueness here: given our set of &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt;
distinct points, there’s only one polynomial of degree &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/189de1175926fa11245f32e4d48aa2a7ab2435b4.svg" style="height: 15px;" type="image/svg+xml"&gt;\leq n&lt;/object&gt;
that interpolates it. We can find its coefficients by inverting the
Vandermonde matrix, by using Lagrange basis functions, or
any other method &lt;a class="footnote-reference" href="#footnote-2" id="footnote-reference-2"&gt;[2]&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="lagrange-polynomials-as-a-basis-for-p-n-mathbb-r"&gt;
&lt;h2&gt;Lagrange polynomials as a basis for &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt;&lt;/h2&gt;
&lt;p&gt;The set &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt; consists of all real polynomials of
degree &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/189de1175926fa11245f32e4d48aa2a7ab2435b4.svg" style="height: 15px;" type="image/svg+xml"&gt;\leq n&lt;/object&gt;. This set - along with addition of polynomials and
scalar multiplication - &lt;a class="reference external" href="https://eli.thegreenplace.net/2026/notes-on-linear-algebra-for-polynomials/"&gt;forms a vector
space&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We called &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt; the &amp;quot;Lagrange basis&amp;quot; previously, and they do -
in fact - form an actual linear algebra basis for this vector space. To
prove this claim, we need to show that Lagrange polynomials are linearly
independent and that they span the space.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Linear independence&lt;/strong&gt;: we have to show that&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/3469cc3e26dc0483fb111f3993bf06b1c5336c53.svg" style="height: 49px;" type="image/svg+xml"&gt;\[s(x)=\sum_{i=0}^{n}a_i l_i(x)=0\]&lt;/object&gt;
&lt;p&gt;implies &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/936812b8cbbba06fa5948bf8f9393e0bd9abc223.svg" style="height: 15px;" type="image/svg+xml"&gt;a_i=0 \quad \forall i&lt;/object&gt;. Recall that &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt; is 1
at &lt;img alt="x_i" class="valign-m3" src="https://eli.thegreenplace.net/images/math/34e03e6559b14df9fe5a97bbd2ed10109dfebbd3.png" style="height: 11px;" /&gt;, while all other &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/1695428630aa1a460c0d7eb95749f04017fb8b60.svg" style="height: 20px;" type="image/svg+xml"&gt;l_j(x)&lt;/object&gt; are 0 at that point.
Therefore, evaluating &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/68cee1190d7058555e058756fed1d6527ab89855.svg" style="height: 19px;" type="image/svg+xml"&gt;s(x)&lt;/object&gt; at &lt;img alt="x_i" class="valign-m3" src="https://eli.thegreenplace.net/images/math/34e03e6559b14df9fe5a97bbd2ed10109dfebbd3.png" style="height: 11px;" /&gt;, we get:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/eda879b68c484c7e88db094e5d4b63e38738503e.svg" style="height: 19px;" type="image/svg+xml"&gt;\[s(x_i)=a_i = 0\]&lt;/object&gt;
&lt;p&gt;Similarly, we can show that &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/1ba9b59bdee92f38c1698c784b67ba70f803331d.svg" style="height: 11px;" type="image/svg+xml"&gt;a_i&lt;/object&gt; is 0, for all &lt;img alt="i" class="valign-0" src="https://eli.thegreenplace.net/images/math/042dc4512fa3d391c5170cf3aa61e6a638f84342.png" style="height: 12px;" /&gt;
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/4a4e9e431da45a27bc880a8a1ca44d8b1b9bc143.svg" style="height: 12px;" type="image/svg+xml"&gt;\blacksquare&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Span&lt;/strong&gt;: we’ve already demonstrated that the linear combination of
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/9e02d7ad79abe9dd4e108d6e33e02bd6b2cece5e.svg" style="height: 49px;" type="image/svg+xml"&gt;\[p(x)=\sum_{i=0}^{n}y_i l_i(x)\]&lt;/object&gt;
&lt;p&gt;is a valid interpolating polynomial for any set of &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; distinct
points. Using the &lt;em&gt;polynomial interpolation theorem&lt;/em&gt;, this is the unique
polynomial interpolating this set of points. In other words, for every
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/ca8eba083582be9ac48f889214d2f74248955c2f.svg" style="height: 19px;" type="image/svg+xml"&gt;q(x)\in P_n(\mathbb{R})&lt;/object&gt;, we can identify any set of &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; distinct points it passes
through, and then use the technique described in this post to find the coefficients of &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/90425caaec1646540a7a9049146bf2606d9dbd0d.svg" style="height: 19px;" type="image/svg+xml"&gt;q(x)&lt;/object&gt; in the
Lagrange basis. Therefore, the set &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/266681d17d2dc06fe4a139a6c0daa4c5c163b300.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x)&lt;/object&gt; spans
the vector space &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/4a4e9e431da45a27bc880a8a1ca44d8b1b9bc143.svg" style="height: 12px;" type="image/svg+xml"&gt;\blacksquare&lt;/object&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="interpolation-matrix-in-the-lagrange-basis"&gt;
&lt;h2&gt;Interpolation matrix in the Lagrange basis&lt;/h2&gt;
&lt;p&gt;Previously we’ve seen how to use the &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/dd30851f93c58a2397e24da06afb6c865f1fd4d6.svg" style="height: 20px;" type="image/svg+xml"&gt;\{1, x, x^2, \dots x^n\}&lt;/object&gt;
basis to write down a system of linear equations that helps us find the
interpolating polynomial. This results in the &lt;em&gt;Vandermonde matrix&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Using the Lagrange basis, we can get a much nicer matrix representation
of the interpolation equations.&lt;/p&gt;
&lt;p&gt;Recall that our general polynomial using the Lagrange basis is:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/e27577760eb802468c6135d93fa6b761cadd55ea.svg" style="height: 49px;" type="image/svg+xml"&gt;\[p(x)=\sum_{i=0}^{n}a_i l_i(x)\]&lt;/object&gt;
&lt;p&gt;Let’s build a system of equations for each of the &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; points
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/224e78a167ad90c8d6434766a835f152b7adcd44.svg" style="height: 19px;" type="image/svg+xml"&gt;(x_i,y_i)&lt;/object&gt;. For &lt;img alt="x_0" class="valign-m3" src="https://eli.thegreenplace.net/images/math/efbda784ad565c1c5201fdc948a570d0426bc6e6.png" style="height: 11px;" /&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/7a62a190b24f3e630c1d267c707dd96329efa545.svg" style="height: 49px;" type="image/svg+xml"&gt;\[p(x_0)=\sum_{i=0}^{n}a_i l_i(x_0)\]&lt;/object&gt;
&lt;p&gt;By definition of the Lagrange basis functions, all &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/dd57195bcdd0b0c2e0f836ee74730425bfd21726.svg" style="height: 19px;" type="image/svg+xml"&gt;l_i(x_0)&lt;/object&gt;
where &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/5722358d633306016b737900981a909e904098bd.svg" style="height: 17px;" type="image/svg+xml"&gt;i\neq 0&lt;/object&gt; are 0, while &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/e45ce17273faa377fac587c644355c089905f5f8.svg" style="height: 19px;" type="image/svg+xml"&gt;l_0(x_0)&lt;/object&gt; is 1. So this
simplifies to:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/c0536313cb1338dd7071c085f52ea51dcb72d79d.svg" style="height: 19px;" type="image/svg+xml"&gt;\[p(x_0)=a_0\]&lt;/object&gt;
&lt;p&gt;But the value at node &lt;img alt="x_0" class="valign-m3" src="https://eli.thegreenplace.net/images/math/efbda784ad565c1c5201fdc948a570d0426bc6e6.png" style="height: 11px;" /&gt; is &lt;img alt="y_0" class="valign-m4" src="https://eli.thegreenplace.net/images/math/2bb5817d0f3bf8490a8c7b1343f84f9635e683a3.png" style="height: 12px;" /&gt;, so we’ve just found
that &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/6df7c1c7fdab6f76ef16a230d6c0b3744017acfd.svg" style="height: 12px;" type="image/svg+xml"&gt;a_0=y_0&lt;/object&gt;. We can produce similar equations for the other
nodes as well, &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7d5f400d37852b1b57adaf0e21efabada38c8363.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x_1)=a_1&lt;/object&gt;, etc. In matrix form:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/d16c76a6af004459db78546a08032c278e9b2a6a.svg" style="height: 159px;" type="image/svg+xml"&gt;\[{\renewcommand{\arraystretch}{1.5}\begin{bmatrix}
     1 &amp;amp; 0 &amp;amp; 0 &amp;amp; \dots &amp;amp; 0\\
     0 &amp;amp; 1 &amp;amp; 0 &amp;amp; \dots &amp;amp; 0\\
     0 &amp;amp; 0 &amp;amp; 1 &amp;amp; \dots &amp;amp; 0\\
     \vdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp;\vdots \\
     0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \dots &amp;amp; 1
 \end{bmatrix}
 \begin{bmatrix}
     a_0\\
     a_1\\
     a_2\\
     \vdots\\
     a_n\\
 \end{bmatrix}=
 \begin{bmatrix}
     y_0\\
     y_1\\
     y_2\\
     \vdots\\
     y_n\\
 \end{bmatrix}
 }\]&lt;/object&gt;
&lt;p&gt;We get the identity matrix; this is another way to trivially show that
&lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/6df7c1c7fdab6f76ef16a230d6c0b3744017acfd.svg" style="height: 12px;" type="image/svg+xml"&gt;a_0=y_0&lt;/object&gt;, &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/8491dd4445d9d585827151312ba90e75fc4859fb.svg" style="height: 12px;" type="image/svg+xml"&gt;a_1=y_1&lt;/object&gt; and so on.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="appendix-vandermonde-matrix"&gt;
&lt;h2&gt;Appendix: Vandermonde matrix&lt;/h2&gt;
&lt;p&gt;Given some numbers &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/0f80294ca0e3cea0ce687973ea5aa7202c1c6f44.svg" style="height: 19px;" type="image/svg+xml"&gt;\{x_0 \dots x_n\}&lt;/object&gt; a matrix of this form:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/a1b91b44ffad5324694b37ed4ed07f5de048d55b.svg" style="height: 159px;" type="image/svg+xml"&gt;\[V=
{\renewcommand{\arraystretch}{1.5}\begin{bmatrix}
1 &amp;amp; x_0 &amp;amp; x_0^2 &amp;amp; \dots &amp;amp; x_0^n\\
1 &amp;amp; x_1 &amp;amp; x_1^2 &amp;amp; \dots &amp;amp; x_1^n\\
1 &amp;amp; x_2 &amp;amp; x_2^2 &amp;amp; \dots &amp;amp; x_2^n\\
\vdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp;\vdots \\
1 &amp;amp; x_n &amp;amp; x_n^2 &amp;amp; \dots &amp;amp; x_n^n
\end{bmatrix}
}\]&lt;/object&gt;
&lt;p&gt;Is called the &lt;em&gt;Vandermonde&lt;/em&gt; matrix. What’s special about a Vandermonde
matrix is that we know it’s invertible when &lt;img alt="x_i" class="valign-m3" src="https://eli.thegreenplace.net/images/math/34e03e6559b14df9fe5a97bbd2ed10109dfebbd3.png" style="height: 11px;" /&gt; are distinct.
This is &lt;a class="reference external" href="https://mathworld.wolfram.com/InvertibleMatrixTheorem.html"&gt;because its determinant is known to be
non-zero&lt;/a&gt;.
Moreover, its determinant is &lt;a class="footnote-reference" href="#footnote-3" id="footnote-reference-3"&gt;[3]&lt;/a&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/aeef2af004a7aeeccdad775b2eaec44543643e90.svg" style="height: 41px;" type="image/svg+xml"&gt;\[\det(V) = \prod_{0 \le i &amp;lt; j \le n} (x_j - x_i)\]&lt;/object&gt;
&lt;p&gt;Here’s why.&lt;/p&gt;
&lt;p&gt;To get some intuition, let’s consider some small-rank Vandermonde
matrices. Starting with a 2-by-2:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/409bf1caaf2ceab8e097d007aacd2e7031185732.svg" style="height: 42px;" type="image/svg+xml"&gt;\[\det(V)=\det\begin{bmatrix}
1 &amp;amp; x_0 \\
1 &amp;amp; x_1 \\
\end{bmatrix}=x_1-x_0\]&lt;/object&gt;
&lt;p&gt;Let’s try 3-by-3 now:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/fa1e9fd7d521588ed1f13cd1ea96c43b56aef604.svg" style="height: 96px;" type="image/svg+xml"&gt;\[\det(V)=\det
{\renewcommand{\arraystretch}{1.5}\begin{bmatrix}
    1 &amp;amp; x_0 &amp;amp; x_0^2 \\
    1 &amp;amp; x_1 &amp;amp; x_1^2 \\
    1 &amp;amp; x_2 &amp;amp; x_2^2 \\
\end{bmatrix}
}\]&lt;/object&gt;
&lt;p&gt;We can use the standard way of calculating determinants to expand from
the first row:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/39f0107408e77d8492349b40106253d18487e48e.svg" style="height: 49px;" type="image/svg+xml"&gt;\[\begin{aligned}
\det(V)&amp;amp;=1\cdot(x_1 x_2^2 - x_2 x_1^2)-x_0(x_2^2-x_1^2)+x_0^2(x_2 - x_1)\\
&amp;amp;=x_1 x_2^2 - x_2 x_1^2 - x_0 x_2^2+x_0 x_1^2+x_0^2 x_2 - x_0^2 x_1\\
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;Using some algebraic manipulation, it’s easy to show this is equivalent
to:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/1cfe17009b539affb81c76120ef3960119bf1a8d.svg" style="height: 19px;" type="image/svg+xml"&gt;\[\det(V)=(x_2-x_1)(x_2-x_0)(x_1-x_0)\]&lt;/object&gt;
&lt;p&gt;For the full proof, let’s look at the generalized
&lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt;-by-&lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; matrix again:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/d93183948364818eeb51b48056262a016e345ef9.svg" style="height: 159px;" type="image/svg+xml"&gt;\[V=
{\renewcommand{\arraystretch}{1.5}\begin{bmatrix}
        1 &amp;amp; x_0 &amp;amp; x_0^2 &amp;amp; \dots &amp;amp; x_0^n\\
        1 &amp;amp; x_1 &amp;amp; x_1^2 &amp;amp; \dots &amp;amp; x_1^n\\
        1 &amp;amp; x_2 &amp;amp; x_2^2 &amp;amp; \dots &amp;amp; x_2^n\\
        \vdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp;\vdots \\
        1 &amp;amp; x_n &amp;amp; x_n^2 &amp;amp; \dots &amp;amp; x_n^n
    \end{bmatrix}
 }\]&lt;/object&gt;
&lt;p&gt;Recall that subtracting a multiple of one column from another doesn’t
change a matrix’s determinant. For each column &lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/1ce658ba27a5ceb614d1279b5e24989689505dcd.svg" style="height: 14px;" type="image/svg+xml"&gt;k&amp;gt;1&lt;/object&gt;, we’ll
subtract the value of column &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/4136a771b69c092ff42aa6115afbc9160e5353c9.svg" style="height: 12px;" type="image/svg+xml"&gt;k-1&lt;/object&gt; multiplied by &lt;img alt="x_0" class="valign-m3" src="https://eli.thegreenplace.net/images/math/efbda784ad565c1c5201fdc948a570d0426bc6e6.png" style="height: 11px;" /&gt; from
it (this is done on all columns simultaneously). The idea is to make the
first row all zeros after the very first element:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/7b17cf508ed83e3f00a056891c02d58bc85df72c.svg" style="height: 159px;" type="image/svg+xml"&gt;\[V=
{\renewcommand{\arraystretch}{1.5}\begin{bmatrix}
        1 &amp;amp; 0 &amp;amp; 0 &amp;amp; \dots &amp;amp; 0\\
        1 &amp;amp; x_1 - x_0 &amp;amp; x_1^2 - x_1 x_0&amp;amp; \dots &amp;amp; x_1^n - x_1^{n-1} x_0\\
        1 &amp;amp; x_2 - x_0 &amp;amp; x_2^2 - x_2 x_0&amp;amp; \dots &amp;amp; x_2^n - x_2^{n-1} x_0\\
        \vdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp;\vdots \\
        1 &amp;amp; x_n - x_0 &amp;amp; x_n^2 - x_n x_0&amp;amp; \dots &amp;amp; x_n^n - x_n^{n-1} x_0\\
    \end{bmatrix}
}\]&lt;/object&gt;
&lt;p&gt;Now we factor out &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/89cce2d73854c97e220aa9b7232bb408e5d1b0d6.svg" style="height: 11px;" type="image/svg+xml"&gt;x_1-x_0&lt;/object&gt; from the second row (after the first
element), &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/9f4f5293a3d0b243932a97c1c52109c3bba378c7.svg" style="height: 11px;" type="image/svg+xml"&gt;x_2-x_0&lt;/object&gt; from the third row and so on, to get:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/0f35e4bc0e43ffcebb6b8ca326dacba9c10549b6.svg" style="height: 159px;" type="image/svg+xml"&gt;\[V=
{\renewcommand{\arraystretch}{1.5}\begin{bmatrix}
        1 &amp;amp; 0 &amp;amp; 0 &amp;amp; \dots &amp;amp; 0\\
        1 &amp;amp; x_1 - x_0 &amp;amp; x_1(x_1 - x_0)&amp;amp; \dots &amp;amp; x_1^{n-1}(x_1 - x_0)\\
        1 &amp;amp; x_2 - x_0 &amp;amp; x_2(x_2 - x_0)&amp;amp; \dots &amp;amp; x_2^{n-1}(x_2 - x_0)\\
        \vdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp;\vdots \\
        1 &amp;amp; x_n - x_0 &amp;amp; x_n(x_n - x_0)&amp;amp; \dots &amp;amp; x_n^{n-1}(x_n - x_0)\\
    \end{bmatrix}
}\]&lt;/object&gt;
&lt;p&gt;Imagine we erase the first row and first column of &lt;img alt="V" class="valign-0" src="https://eli.thegreenplace.net/images/math/c9ee5681d3c59f7541c27a38b67edf46259e187b.png" style="height: 12px;" /&gt;. We’ll call
the resulting matrix &lt;img alt="W" class="valign-0" src="https://eli.thegreenplace.net/images/math/e2415cb7f63df0c9de23362326ad3c37a9adfc96.png" style="height: 12px;" /&gt;.&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/bd6c93bd0a0454bce81c7565870e59033bffd317.svg" style="height: 128px;" type="image/svg+xml"&gt;\[W=
{\renewcommand{\arraystretch}{1.5}\begin{bmatrix}
        x_1 - x_0 &amp;amp; x_1(x_1 - x_0)&amp;amp; \dots &amp;amp; x_1^{n-1}(x_1 - x_0)\\
        x_2 - x_0 &amp;amp; x_2(x_2 - x_0)&amp;amp; \dots &amp;amp; x_2^{n-1}(x_2 - x_0)\\
        \vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp;\vdots \\
        x_n - x_0 &amp;amp; x_n(x_n - x_0)&amp;amp; \dots &amp;amp; x_n^{n-1}(x_n - x_0)\\
    \end{bmatrix}
}\]&lt;/object&gt;
&lt;p&gt;Because the first row of &lt;img alt="V" class="valign-0" src="https://eli.thegreenplace.net/images/math/c9ee5681d3c59f7541c27a38b67edf46259e187b.png" style="height: 12px;" /&gt; is all zeros except the first
element, we have:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/c112a75142ecd4bc97e681cf01e4a734a67e9c5d.svg" style="height: 19px;" type="image/svg+xml"&gt;\[\det(V)=\det(W)\]&lt;/object&gt;
&lt;p&gt;Note that the first row of &lt;img alt="W" class="valign-0" src="https://eli.thegreenplace.net/images/math/e2415cb7f63df0c9de23362326ad3c37a9adfc96.png" style="height: 12px;" /&gt; has a common factor of
&lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/89cce2d73854c97e220aa9b7232bb408e5d1b0d6.svg" style="height: 11px;" type="image/svg+xml"&gt;x_1-x_0&lt;/object&gt;, so when calculating &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/3845b3a938b1cd6b8667c495a8caa9957a8ee224.svg" style="height: 19px;" type="image/svg+xml"&gt;\det(W)&lt;/object&gt;, we can move this
common factor out. Same for the common factor &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/9f4f5293a3d0b243932a97c1c52109c3bba378c7.svg" style="height: 11px;" type="image/svg+xml"&gt;x_2-x_0&lt;/object&gt; of the
second row, and so on. Overall, we can write:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/d55d4c9c9a66ca0f092d2bddf159c61b8db12896.svg" style="height: 128px;" type="image/svg+xml"&gt;\[\det(W)=(x_1-x_0)(x_2-x_0)\cdots(x_n-x_0)\cdot \det
{\renewcommand{\arraystretch}{1.5}\begin{bmatrix}
        1 &amp;amp; x_1 &amp;amp; x_1^2 &amp;amp; \dots &amp;amp; x_1^{n-1}\\
        1 &amp;amp; x_2 &amp;amp; x_2^2 &amp;amp; \dots &amp;amp; x_2^{n-1}\\
        \vdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp;\vdots \\
        1 &amp;amp; x_n &amp;amp; x_n^2 &amp;amp; \dots &amp;amp; x_n^{n-1}
    \end{bmatrix}
}\]&lt;/object&gt;
&lt;p&gt;But the smaller matrix is just the Vandermonde matrix for
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/280962e0b640e843643a0554e19a3938aec8cb31.svg" style="height: 19px;" type="image/svg+xml"&gt;\{x_1 \dots x_{n}\}&lt;/object&gt;. If we continue this process by induction,
we’ll get:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/aeef2af004a7aeeccdad775b2eaec44543643e90.svg" style="height: 41px;" type="image/svg+xml"&gt;\[\det(V) = \prod_{0 \le i &amp;lt; j \le n} (x_j - x_i)\]&lt;/object&gt;
&lt;p&gt;If you’re interested, the &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Vandermonde_matrix"&gt;Wikipedia page for the Vandermonde matrix&lt;/a&gt; has a couple of additional
proofs.&lt;/p&gt;
&lt;hr class="docutils" /&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-1" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-1"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;The &lt;img alt="x" class="valign-0" src="https://eli.thegreenplace.net/images/math/11f6ad8ec52a2984abaafd7c3b516503785c2072.png" style="height: 8px;" /&gt;-es here are called &lt;em&gt;nodes&lt;/em&gt; and the &lt;img alt="y" class="valign-m4" src="https://eli.thegreenplace.net/images/math/95cb0bfd2977c761298d9624e4b4d4c72a39974a.png" style="height: 12px;" /&gt;-s are
called &lt;em&gt;values&lt;/em&gt;.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-2" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-2"&gt;[2]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a class="reference external" href="https://eli.thegreenplace.net/2024/method-of-differences-and-newton-polynomials/"&gt;Newton
polynomials&lt;/a&gt;
is also an option, and there are many other approaches.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-3" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-3"&gt;[3]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Note that this means the product of all differences between
&lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/73058e43db0f4edc791b10f27f913cbc5d361ab6.svg" style="height: 14px;" type="image/svg+xml"&gt;x_j&lt;/object&gt; and &lt;img alt="x_i" class="valign-m3" src="https://eli.thegreenplace.net/images/math/34e03e6559b14df9fe5a97bbd2ed10109dfebbd3.png" style="height: 11px;" /&gt; where &lt;img alt="i" class="valign-0" src="https://eli.thegreenplace.net/images/math/042dc4512fa3d391c5170cf3aa61e6a638f84342.png" style="height: 12px;" /&gt; is strictly smaller than
&lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/5c2dd944dde9e08881bef0894fe7b22a5c9c4b06.svg" style="height: 16px;" type="image/svg+xml"&gt;j&lt;/object&gt;. That is, for &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/2091fb295870e9f79b6d8a10d0f6046b091e6fe5.svg" style="height: 12px;" type="image/svg+xml"&gt;n=2&lt;/object&gt;, the full product is
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/c42a249f6023c731a0d670240a66413cd79aee91.svg" style="height: 19px;" type="image/svg+xml"&gt;(x_2-x_1)(x_2-x_0)(x_1-x_0)&lt;/object&gt;. For an arbitrary &lt;img alt="n" class="valign-0" src="https://eli.thegreenplace.net/images/math/d1854cae891ec7b29161ccaf79a24b00c274bdaa.png" style="height: 8px;" /&gt;,
there are &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/66a19249b26d808e85ea349b8b84dee8a2090e0c.svg" style="height: 25px;" type="image/svg+xml"&gt;\frac{n(n-1)}{2}&lt;/object&gt; factors in total.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
</content><category term="misc"></category><category term="Math"></category></entry><entry><title>Notes on Linear Algebra for Polynomials</title><link href="https://eli.thegreenplace.net/2026/notes-on-linear-algebra-for-polynomials/" rel="alternate"></link><published>2026-02-25T18:34:00-08:00</published><updated>2026-04-30T02:30:02-07:00</updated><author><name>Eli Bendersky</name></author><id>tag:eli.thegreenplace.net,2026-02-25:/2026/notes-on-linear-algebra-for-polynomials/</id><summary type="html">&lt;p&gt;We’ll be working with the set &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt;, real polynomials
of degree &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/189de1175926fa11245f32e4d48aa2a7ab2435b4.svg" style="height: 15px;" type="image/svg+xml"&gt;\leq n&lt;/object&gt;. Such polynomials can be expressed using
&lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; scalar coefficients &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/1ba9b59bdee92f38c1698c784b67ba70f803331d.svg" style="height: 11px;" type="image/svg+xml"&gt;a_i&lt;/object&gt; as follows:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/dedb05af255bc66694c47ba554c5366bdc3b2e12.svg" style="height: 22px;" type="image/svg+xml"&gt;\[p(x)=a_0+a_1 x + a_2 x^2 + \cdots + a_n x^n\]&lt;/object&gt;
&lt;div class="section" id="vector-space"&gt;
&lt;h2&gt;Vector space&lt;/h2&gt;
&lt;p&gt;The set &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt;, along with …&lt;/p&gt;&lt;/div&gt;</summary><content type="html">&lt;p&gt;We’ll be working with the set &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt;, real polynomials
of degree &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/189de1175926fa11245f32e4d48aa2a7ab2435b4.svg" style="height: 15px;" type="image/svg+xml"&gt;\leq n&lt;/object&gt;. Such polynomials can be expressed using
&lt;object class="valign-m2" data="https://eli.thegreenplace.net/images/math/db2a943efe93404e43f6ecbec79e0a4fe81b1649.svg" style="height: 14px;" type="image/svg+xml"&gt;n+1&lt;/object&gt; scalar coefficients &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/1ba9b59bdee92f38c1698c784b67ba70f803331d.svg" style="height: 11px;" type="image/svg+xml"&gt;a_i&lt;/object&gt; as follows:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/dedb05af255bc66694c47ba554c5366bdc3b2e12.svg" style="height: 22px;" type="image/svg+xml"&gt;\[p(x)=a_0+a_1 x + a_2 x^2 + \cdots + a_n x^n\]&lt;/object&gt;
&lt;div class="section" id="vector-space"&gt;
&lt;h2&gt;Vector space&lt;/h2&gt;
&lt;p&gt;The set &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt;, along with addition of polynomials and
scalar multiplication form a &lt;em&gt;vector space&lt;/em&gt;. As a proof, let’s review
how the vector space axioms are satisfied. We’ll use &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt;,
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/90425caaec1646540a7a9049146bf2606d9dbd0d.svg" style="height: 19px;" type="image/svg+xml"&gt;q(x)&lt;/object&gt; and &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/9468a2656a6201bfa194ec81fb0f78352c9666c9.svg" style="height: 19px;" type="image/svg+xml"&gt;r(x)&lt;/object&gt; as arbitrary polynomials from the set
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt; for the demonstration. Similarly, &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8.svg" style="height: 8px;" type="image/svg+xml"&gt;a&lt;/object&gt; and
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98.svg" style="height: 13px;" type="image/svg+xml"&gt;b&lt;/object&gt; are arbitrary scalars in &lt;img alt="\mathbb{R}" class="valign-0" src="https://eli.thegreenplace.net/images/math/0ed839b111fe0e3ca2b2f618b940893eaea88a57.png" style="height: 12px;" /&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Associativity of vector addition&lt;/strong&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/45656c48313e3e3566577fdf014d18f31080ed42.svg" style="height: 19px;" type="image/svg+xml"&gt;\[p(x)+[q(x)+r(x)]=p(x)+q(x)+r(x)=[p(x)+q(x)]+r(x)\]&lt;/object&gt;
&lt;p&gt;This is trivial because addition of polynomials is associative  &lt;a class="footnote-reference" href="#footnote-1" id="footnote-reference-1"&gt;[1]&lt;/a&gt;.
Commutativity is similarly trivial, for the same reason:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Commutativity of vector addition&lt;/strong&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/4e72ebe69a19da51a0e7319eaa997c671024d3c6.svg" style="height: 19px;" type="image/svg+xml"&gt;\[p(x)+q(x)=q(x)+p(x)\]&lt;/object&gt;
&lt;p&gt;&lt;strong&gt;Identity element of vector addition&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;The zero polynomial 0 serves as an identity element.
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/1910380c6f610451862989641479600496131408.svg" style="height: 19px;" type="image/svg+xml"&gt;\forall p(x)\in P_n(\mathbb{R})&lt;/object&gt;, we have
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/d5aec4c833b53c3aee94eed8b9d7c6bd8bb577d9.svg" style="height: 19px;" type="image/svg+xml"&gt;0 + p(x) = p(x)&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Inverse element of vector addition&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;For each &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt;, we can use &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/eaa3a7a017152661a9e148063a189da51e966773.svg" style="height: 19px;" type="image/svg+xml"&gt;q(x)=-p(x)&lt;/object&gt; as the additive
inverse, because &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/a178e59633deb255cbecbdaecb1980ee53ec94c7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)+q(x)=0&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Identity element of scalar multiplication&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The scalar 1 serves as an identity element for scalar multiplication.
For each &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt;, it’s true that &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/5ba95500b0306ee6283d5d71d1a6aa41c2c0b35b.svg" style="height: 19px;" type="image/svg+xml"&gt;1\cdot p(x)=p(x)&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Associativity of scalar multiplication&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;For any two scalars &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8.svg" style="height: 8px;" type="image/svg+xml"&gt;a&lt;/object&gt; and &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98.svg" style="height: 13px;" type="image/svg+xml"&gt;b&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/bc050a41a2584e826e96409fb19fda0347fa9b69.svg" style="height: 19px;" type="image/svg+xml"&gt;\[a[b\cdot p(x)]=ab\cdot p(x)=[ab]\cdot p(x)\]&lt;/object&gt;
&lt;p&gt;&lt;strong&gt;Distributivity of scalar multiplication over vector addition&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;For any &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt;, &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/90425caaec1646540a7a9049146bf2606d9dbd0d.svg" style="height: 19px;" type="image/svg+xml"&gt;q(x)&lt;/object&gt; and scalar &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8.svg" style="height: 8px;" type="image/svg+xml"&gt;a&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/5e0141340db285d60c642b145119b3f279e77518.svg" style="height: 19px;" type="image/svg+xml"&gt;\[a\cdot[p(x)+q(x)]=a\cdot p(x)+a\cdot q(x)\]&lt;/object&gt;
&lt;p&gt;&lt;strong&gt;Distributivity of scalar multiplication over scalar addition&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;For any scalars &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8.svg" style="height: 8px;" type="image/svg+xml"&gt;a&lt;/object&gt; and &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98.svg" style="height: 13px;" type="image/svg+xml"&gt;b&lt;/object&gt; and polynomial &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/29085125ec39218fe745bc4bf6f2aac269a42442.svg" style="height: 19px;" type="image/svg+xml"&gt;\[[a+b]\cdot p(x)=a\cdot p(x) + b\cdot p(x)\]&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="linear-independence-span-and-basis"&gt;
&lt;h2&gt;Linear independence, span and basis&lt;/h2&gt;
&lt;p&gt;Since we’ve shown that polynomials in &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt; form a
vector space, we can now build additional linear algebraic definitions
on top of that.&lt;/p&gt;
&lt;p&gt;A set of &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/13fbd79c3d390e5d6585a21e11ff5ec1970cff0c.svg" style="height: 12px;" type="image/svg+xml"&gt;k&lt;/object&gt; polynomials &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/5375fa35be4aee1860db8d7f943aa13b9a6983c2.svg" style="height: 19px;" type="image/svg+xml"&gt;p_k(x)\in P_n(\mathbb{R})&lt;/object&gt; is said
to be &lt;em&gt;linearly independent&lt;/em&gt; if&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/11f5abb0d3349e337653153e9932b683f33cf5f3.svg" style="height: 53px;" type="image/svg+xml"&gt;\[\sum_{i=1}^{k}a_i p_i(x)=0\]&lt;/object&gt;
&lt;p&gt;implies &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/936812b8cbbba06fa5948bf8f9393e0bd9abc223.svg" style="height: 15px;" type="image/svg+xml"&gt;a_i=0 \quad \forall i&lt;/object&gt;. In words, the only linear
combination resulting in the zero vector is when all coefficients are 0.&lt;/p&gt;
&lt;p&gt;As an example, let’s discuss the fundamental building blocks of
polynomials in &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt;: the set
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/dd30851f93c58a2397e24da06afb6c865f1fd4d6.svg" style="height: 20px;" type="image/svg+xml"&gt;\{1, x, x^2, \dots x^n\}&lt;/object&gt;. These are linearly independent
because:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/9a1a0398b10978c0bb81a5ee5e9392e12c3fb031.svg" style="height: 19px;" type="image/svg+xml"&gt;\[a_0 + a_1 x + a_2 x^2 + \cdots a_n x^n=0\]&lt;/object&gt;
&lt;p&gt;is true only for zero polynomial, in which all the coefficients
&lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/fc7c49cdcf0b6f4f244a8e180fc8df4513e6a42e.svg" style="height: 15px;" type="image/svg+xml"&gt;a_i=0&lt;/object&gt;. This comes from the very definition of polynomials.
Moreover, this set &lt;em&gt;spans&lt;/em&gt; the entire &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt; because
every polynomial can be (by definition) expressed as a linear combination of
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/dd30851f93c58a2397e24da06afb6c865f1fd4d6.svg" style="height: 20px;" type="image/svg+xml"&gt;\{1, x, x^2, \dots x^n\}&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;Since we’ve shown these basic polynomials are linearly independent and
span the entire vector space, they are a &lt;em&gt;basis&lt;/em&gt; for the space. In fact,
this set has a special name: the &lt;em&gt;monomial basis&lt;/em&gt; (because a monomial is
a polynomial with a single term).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="checking-if-an-arbitrary-set-of-polynomials-is-a-basis"&gt;
&lt;h2&gt;Checking if an arbitrary set of polynomials is a basis&lt;/h2&gt;
&lt;p&gt;Suppose we have some set polynomials, and we want to know if these form
a basis for &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt;. How do we go about it?&lt;/p&gt;
&lt;p&gt;The idea is using linear algebra the same way we do for any other vector
space. Let’s use a concrete example to demonstrate:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/0a1ff12f973cf607bf879deb912333051a671de5.svg" style="height: 22px;" type="image/svg+xml"&gt;\[Q=\{1-x, x, 2x+x^2\}\]&lt;/object&gt;
&lt;p&gt;Is the set &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/c3156e00d3c2588c639e0d3cf6821258b05761c7.svg" style="height: 16px;" type="image/svg+xml"&gt;Q&lt;/object&gt; a basis for &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/8d9aa0df1179c6e216d3a92cd70fe12bc29363bd.svg" style="height: 19px;" type="image/svg+xml"&gt;P_2(\mathbb{R})&lt;/object&gt;? We’ll start by
checking whether the members of &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/c3156e00d3c2588c639e0d3cf6821258b05761c7.svg" style="height: 16px;" type="image/svg+xml"&gt;Q&lt;/object&gt; are linearly independent.
Write:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/41bdcc040d729f93edeb130b51a9ac3ee66b72d5.svg" style="height: 22px;" type="image/svg+xml"&gt;\[a_0(1-x)+a_1 x + a_2(2x+x^2)=0\]&lt;/object&gt;
&lt;p&gt;By regrouping, we can turn this into:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/73036a5532059c810bb37bd3a8dc1abdb85c9b1f.svg" style="height: 22px;" type="image/svg+xml"&gt;\[a_0 + (a_1-a_0+2a_2)x+a_2 x^2=0\]&lt;/object&gt;
&lt;p&gt;For this to be true, the coefficient of each monomial has to be zero;
mathematically:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/4e5d5010eec23b675caf4b1936082d48a0b9ec1f.svg" style="height: 65px;" type="image/svg+xml"&gt;\[\begin{aligned}
    a_0&amp;amp;=0\\
    a_1-a_0+2a_2&amp;amp;=0\\
    a2&amp;amp;=0\\
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;In matrix form:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/78c214c04a41b196844997d84ceeb8df0e5d76e2.svg" style="height: 64px;" type="image/svg+xml"&gt;\[\begin{bmatrix}
    1 &amp;amp; 0 &amp;amp; 0\\
    -1 &amp;amp; 1 &amp;amp; 2\\
    0 &amp;amp; 0 &amp;amp; 1\\
\end{bmatrix}
\begin{bmatrix}a_0\\ a_1\\ a_2\end{bmatrix}
=\begin{bmatrix}0\\ 0\\ 0\end{bmatrix}\]&lt;/object&gt;
&lt;p&gt;We know how to solve this, by reducing the matrix into &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Row_echelon_form"&gt;row-echelon
form&lt;/a&gt;. It’s easy to
see that the reduced row-echelon form of this specific matrix is
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/ca73ab65568cd125c2d27a22bbd9e863c10b675d.svg" style="height: 12px;" type="image/svg+xml"&gt;I&lt;/object&gt;, the identity matrix. Therefore, this set of equations has a
single solution: &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/936812b8cbbba06fa5948bf8f9393e0bd9abc223.svg" style="height: 15px;" type="image/svg+xml"&gt;a_i=0 \quad \forall i&lt;/object&gt;  &lt;a class="footnote-reference" href="#footnote-2" id="footnote-reference-2"&gt;[2]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We’ve shown that the set &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/c3156e00d3c2588c639e0d3cf6821258b05761c7.svg" style="height: 16px;" type="image/svg+xml"&gt;Q&lt;/object&gt; is linearly independent. Now let’s
show that it &lt;em&gt;spans&lt;/em&gt; the space &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/8d9aa0df1179c6e216d3a92cd70fe12bc29363bd.svg" style="height: 19px;" type="image/svg+xml"&gt;P_2(\mathbb{R})&lt;/object&gt;. We want to
analyze:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/4ddca074738e89bc063a29a7cd67215ada8fffe5.svg" style="height: 22px;" type="image/svg+xml"&gt;\[a_0(1-x)+a_1 x + a_2(2x+x^2)=\alpha +\beta x + \gamma x^2\]&lt;/object&gt;
&lt;p&gt;And find the coefficients &lt;object class="valign-m3" data="https://eli.thegreenplace.net/images/math/1ba9b59bdee92f38c1698c784b67ba70f803331d.svg" style="height: 11px;" type="image/svg+xml"&gt;a_i&lt;/object&gt; that satisfy this for any
arbitrary &lt;img alt="\alpha" class="valign-0" src="https://eli.thegreenplace.net/images/math/f7c665b45932a814215e979bc2611080b4948e68.png" style="height: 8px;" /&gt;, &lt;img alt="\beta" class="valign-m4" src="https://eli.thegreenplace.net/images/math/6499d503bfc00cadae1440b191c52a8632e2f8c4.png" style="height: 16px;" /&gt; and &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/67833ee2012ec1c6254b6c009dc72bf0dc48aa6d.svg" style="height: 12px;" type="image/svg+xml"&gt;\gamma&lt;/object&gt;. We proceed
just as before, by regrouping on the left side:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/7bcb2f196e39a4b859cddf4123ee02481940fafa.svg" style="height: 22px;" type="image/svg+xml"&gt;\[a_0 + (a_1-a_0+2a_2)x+a_2 x^2=\alpha +\beta x + \gamma x^2\]&lt;/object&gt;
&lt;p&gt;and equating the coefficient of each power of &lt;img alt="x" class="valign-0" src="https://eli.thegreenplace.net/images/math/11f6ad8ec52a2984abaafd7c3b516503785c2072.png" style="height: 8px;" /&gt; separately:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/f32a037534eba0f569a01b0d2e763b9ff3c54587.svg" style="height: 65px;" type="image/svg+xml"&gt;\[\begin{aligned}
    a_0&amp;amp;=\alpha\\
    a_1-a_0+2a_2&amp;amp;=\beta\\
    a2&amp;amp;=\gamma\\
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;If we turn this into matrix form, the matrix of coefficients is exactly
the same as before. So we know there’s a single solution, and by
rearranging the matrix into &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/ca73ab65568cd125c2d27a22bbd9e863c10b675d.svg" style="height: 12px;" type="image/svg+xml"&gt;I&lt;/object&gt;, the solution will appear on the
right hand side. It doesn’t matter for the moment what the actual
solution is, as long as it exists and is unique. We’ve shown that
&lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/c3156e00d3c2588c639e0d3cf6821258b05761c7.svg" style="height: 16px;" type="image/svg+xml"&gt;Q&lt;/object&gt; spans the space!&lt;/p&gt;
&lt;p&gt;Since the set &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/c3156e00d3c2588c639e0d3cf6821258b05761c7.svg" style="height: 16px;" type="image/svg+xml"&gt;Q&lt;/object&gt; is linearly independent and spans
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/8d9aa0df1179c6e216d3a92cd70fe12bc29363bd.svg" style="height: 19px;" type="image/svg+xml"&gt;P_2(\mathbb{R})&lt;/object&gt;, it is a &lt;em&gt;basis&lt;/em&gt; for the space.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="inner-product"&gt;
&lt;h2&gt;Inner product&lt;/h2&gt;
&lt;p&gt;I’ve discussed inner products for functions in &lt;a class="reference external" href="https://eli.thegreenplace.net/2025/hilbert-space-treating-functions-as-vectors/"&gt;the post about Hilbert
space&lt;/a&gt;.
Well, &lt;em&gt;polynomials are functions&lt;/em&gt;, so we can define an inner product
using integrals as follows &lt;a class="footnote-reference" href="#footnote-3" id="footnote-reference-3"&gt;[3]&lt;/a&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/a7073ffb2e322d7c7b9118b0fcc517c0c484fcb3.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\langle p, q \rangle = \int_{a}^{b} p(x) q(x) w(x) \, dx\]&lt;/object&gt;
&lt;p&gt;Where the bounds &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8.svg" style="height: 8px;" type="image/svg+xml"&gt;a&lt;/object&gt; and &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98.svg" style="height: 13px;" type="image/svg+xml"&gt;b&lt;/object&gt; are arbitrary, and could be
infinite. Whenever we deal with integrals we worry about convergence; in
my post on Hilbert spaces, we only talked about &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/f1aae083af2c79348dd78712847ebd55537fa6e6.svg" style="height: 15px;" type="image/svg+xml"&gt;L^2&lt;/object&gt; - the square
integrable functions. Most polynomials are not square integrable,
however. Therefore, we can restrict this using either:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;A special &lt;em&gt;weight function&lt;/em&gt; &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/02e80b7cfa178127b4c5282079352105a2c55cf7.svg" style="height: 19px;" type="image/svg+xml"&gt;w(x)&lt;/object&gt; to make sure the inner
product integral converges&lt;/li&gt;
&lt;li&gt;Set finite bounds on the integral, and then we can just set
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/62c32bb13769e79e5a65343da35baaa514b873e3.svg" style="height: 19px;" type="image/svg+xml"&gt;w(x)=1&lt;/object&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let’s use the latter, and restrict the bounds into the range
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/d5610f38fe75d8d90ac09fd335bad6823492589d.svg" style="height: 18px;" type="image/svg+xml"&gt;[-1,1]&lt;/object&gt;, setting &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/62c32bb13769e79e5a65343da35baaa514b873e3.svg" style="height: 19px;" type="image/svg+xml"&gt;w(x)=1&lt;/object&gt;. We have the following inner
product:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/9f9575d1c81856a7fd8b8b71352a33119fe023e3.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\langle p, q \rangle = \int_{-1}^{1} p(x) q(x) \, dx\]&lt;/object&gt;
&lt;p&gt;Let’s check that this satisfies the inner product space conditions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Conjugate symmetry&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;Since real multiplication is commutative, we can write:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/e5584cd03887f39cb8b7c8cbec3ca64a1d4347da.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\langle p, q \rangle = \int_{-1}^{1} p(x) q(x) \, dx =\int_{-1}^{1} q(x) p(x) \, dx=\langle q, p \rangle\]&lt;/object&gt;
&lt;p&gt;We deal in the reals here, so we can safely ignore complex conjugation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Linearity in the first argument&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;Let &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/c9b738cad43aea3a80a02e1f075a09868eb73e26.svg" style="height: 19px;" type="image/svg+xml"&gt;p_1,p_2,q\in P_n(\mathbb{R})&lt;/object&gt; and &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/44a2f2358e9ec13e88b5a266ee1bd804a43c5864.svg" style="height: 16px;" type="image/svg+xml"&gt;a,b\in \mathbb{R}&lt;/object&gt;.
We want to show that&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/d25bedb6d14cf20fbf28b583412dfd9ac14f6cf3.svg" style="height: 19px;" type="image/svg+xml"&gt;\[\langle ap_1+bp_2,q \rangle = a\langle p_1,q\rangle +b\langle p_2,q\rangle\]&lt;/object&gt;
&lt;p&gt;Expand the left-hand side using our definition of inner product:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/3549d9fc0999c0fadd0458ece4609f5b08780052.svg" style="height: 95px;" type="image/svg+xml"&gt;\[\begin{aligned}
    \langle ap_1+bp_2,q \rangle&amp;amp;=\int_{-1}^{1} (a p_1(x)+b p_2(x)) q(x) \, dx\\
    &amp;amp;=a\int_{-1}^{1} p_1(x) q(x) \, dx+b\int_{-1}^{1} p_2(x) q(x) \, dx
\end{aligned}\]&lt;/object&gt;
&lt;p&gt;The result is equivalent to
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7239344e074d1e86c42e73c5470999705411aacc.svg" style="height: 19px;" type="image/svg+xml"&gt;a\langle p_1,q\rangle +b\langle p_2,q\rangle&lt;/object&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Positive-definiteness&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;We want to show that for nonzero &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/8a22a4ced0990db5e8d521832fddacd240fc599f.svg" style="height: 19px;" type="image/svg+xml"&gt;p\in P_n(\mathbb{R})&lt;/object&gt;, we have
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/c8d11b2d1c5d8a6529b6068917407194be2a7b2d.svg" style="height: 19px;" type="image/svg+xml"&gt;\langle p, p\rangle &amp;gt; 0&lt;/object&gt;. First of all, since &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/5e91383f4084e35136e78c00570cf313965465e9.svg" style="height: 20px;" type="image/svg+xml"&gt;p(x)^2\geq0&lt;/object&gt;
for all &lt;img alt="x" class="valign-0" src="https://eli.thegreenplace.net/images/math/11f6ad8ec52a2984abaafd7c3b516503785c2072.png" style="height: 8px;" /&gt;, it’s true that:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/44dd56558739e571dee1200a50039374e485e05b.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\langle p, p\rangle=\int_{-1}^{1}p(x)^2\, dx\geq 0\]&lt;/object&gt;
&lt;p&gt;What about the result 0 though? Well, let’s say that&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/31b9ef374de82013e825fc205670d3ebe0dfc541.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\int_{-1}^{1}p(x)^2\, dx=0\]&lt;/object&gt;
&lt;p&gt;Since &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/11bf1f75edece9993925ac94a0a1f158762c2111.svg" style="height: 20px;" type="image/svg+xml"&gt;p(x)^2&lt;/object&gt; is a non-negative function, this means that the
integral of a non-negative function ends up being 0. But &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/7f86e6c6bb632c1ca2518f269fc1cc1b6737d4f7.svg" style="height: 19px;" type="image/svg+xml"&gt;p(x)&lt;/object&gt; is
a polynomial, so it’s &lt;em&gt;continuous&lt;/em&gt;, and so is &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/11bf1f75edece9993925ac94a0a1f158762c2111.svg" style="height: 20px;" type="image/svg+xml"&gt;p(x)^2&lt;/object&gt;. If the
integral of a continuous non-negative function is 0, it means the
function itself is 0. Had it been non-zero in any place, the integral
would necessarily have to be positive as well.&lt;/p&gt;
&lt;p&gt;We’ve proven that &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/9de22135888f7085d51d8b1cbd987d2c68a050ec.svg" style="height: 19px;" type="image/svg+xml"&gt;\langle p, p\rangle=0&lt;/object&gt; only when &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/516b9783fca517eecbd1d064da2d165310b19759.svg" style="height: 12px;" type="image/svg+xml"&gt;p&lt;/object&gt; is
the zero polynomial. The positive-definiteness condition is satisfied.&lt;/p&gt;
&lt;p&gt;In conclusion, &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt; along with the inner product
we’ve defined forms an &lt;em&gt;inner product space&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="orthogonality"&gt;
&lt;h2&gt;Orthogonality&lt;/h2&gt;
&lt;p&gt;Now that we have an inner product, we can define orthogonality on
polynomials: two polynomials &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/d2926c1571d4e1b8561077d3308b7cfb6d211e59.svg" style="height: 12px;" type="image/svg+xml"&gt;p,q&lt;/object&gt; are &lt;em&gt;orthogonal&lt;/em&gt; (w.r.t. our
inner product) iff&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/b994221c38da6d42afb973d4318ac59c4940f545.svg" style="height: 44px;" type="image/svg+xml"&gt;\[\langle p,q\rangle=\int_{-1}^{1}p(x)q(x)\, dx=0\]&lt;/object&gt;
&lt;p&gt;Contrary to expectation  &lt;a class="footnote-reference" href="#footnote-4" id="footnote-reference-4"&gt;[4]&lt;/a&gt;, the monomial basis polynomials are &lt;em&gt;not&lt;/em&gt;
orthogonal using our definition of inner product.&lt;/p&gt;
&lt;p&gt;For example, calculating the inner product for &lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/356a192b7913b04c54574d18c28d46e6395428ab.svg" style="height: 12px;" type="image/svg+xml"&gt;1&lt;/object&gt; and
&lt;object class="valign-0" data="https://eli.thegreenplace.net/images/math/7046d961a8144b7b2c2da6066849a9f889ff2ac9.svg" style="height: 15px;" type="image/svg+xml"&gt;x^2&lt;/object&gt;:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/c6937eec30d2a69a76efdbd489e70d3ad18c0c29.svg" style="height: 47px;" type="image/svg+xml"&gt;\[\langle 1,x^2\rangle=\int_{-1}^{1}x^2\, dx=\frac{x^3}{3}\biggr|_{-1}^{1}=\frac{2}{3}\]&lt;/object&gt;
&lt;p&gt;There are other sets of polynomials that &lt;em&gt;are&lt;/em&gt; orthogonal using our
inner product. For example, the &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Legendre_polynomials"&gt;Legendre
polynomials&lt;/a&gt;; but
this is a topic for another post.&lt;/p&gt;
&lt;hr class="docutils" /&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-1" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-1"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;There’s a level of basic algebra below which we won’t descend in
these notes. We could break this statement further down by saying
that something like &lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/bdcf820e656d6ef78cf1729b58556a6a9e2e9fd4.svg" style="height: 21px;" type="image/svg+xml"&gt;a_i x^i + a_j x^j&lt;/object&gt; can be added to
&lt;object class="valign-m6" data="https://eli.thegreenplace.net/images/math/e2d0aea0ffca9c5c9870d56c7f0247349f759f49.svg" style="height: 21px;" type="image/svg+xml"&gt;b_i x^i + b_j x^j&lt;/object&gt; by adding each power of &lt;img alt="x" class="valign-0" src="https://eli.thegreenplace.net/images/math/11f6ad8ec52a2984abaafd7c3b516503785c2072.png" style="height: 8px;" /&gt;
separately for any &lt;img alt="i" class="valign-0" src="https://eli.thegreenplace.net/images/math/042dc4512fa3d391c5170cf3aa61e6a638f84342.png" style="height: 12px;" /&gt; and &lt;object class="valign-m4" data="https://eli.thegreenplace.net/images/math/5c2dd944dde9e08881bef0894fe7b22a5c9c4b06.svg" style="height: 16px;" type="image/svg+xml"&gt;j&lt;/object&gt;, but let’s just take it
for granted.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-2" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-2"&gt;[2]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Obviously, this specific set of equations is quite trivial to solve
without matrices; I just want to demonstrate the more general
approach. Once we have a system of linear equations, the whole
toolbox of linear algebra is at our disposal. For example, we could
also have checked the determinant and seen it’s non-zero, which means
that a square matrix is invertible, and in this case has a single
solution of zeroes.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-3" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-3"&gt;[3]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;And actually with this (or any valid) inner product,
&lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt; indeed forms a Hilbert space, because it’s
finite-dimensional, and every finite-dimensional inner product space
is complete.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-4" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-4"&gt;[4]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Because of how naturally this set spans &lt;object class="valign-m5" data="https://eli.thegreenplace.net/images/math/66e617fc4a3781fe03dcf20effb656feaa81a47e.svg" style="height: 19px;" type="image/svg+xml"&gt;P_n(\mathbb{R})&lt;/object&gt;. And
indeed, we can define alternative inner products using which
monomials are orthogonal.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
</content><category term="misc"></category><category term="Math"></category></entry><entry><title>LaTeX, LLMs and Boring Technology</title><link href="https://eli.thegreenplace.net/2025/latex-llms-and-boring-technology/" rel="alternate"></link><published>2025-10-25T06:20:00-07:00</published><updated>2025-10-25T13:23:02-07:00</updated><author><name>Eli Bendersky</name></author><id>tag:eli.thegreenplace.net,2025-10-25:/2025/latex-llms-and-boring-technology/</id><summary type="html">&lt;p&gt;Depending on your particular use case, &lt;a class="reference external" href="https://boringtechnology.club/"&gt;choosing boring technology&lt;/a&gt;
is often a good idea. Recently, I've been thinking more and more about how
the rise and increase in power of LLMs affects this choice.&lt;/p&gt;
&lt;p&gt;By definition, boring technology has been around for a long time. Piles of
content have been …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Depending on your particular use case, &lt;a class="reference external" href="https://boringtechnology.club/"&gt;choosing boring technology&lt;/a&gt;
is often a good idea. Recently, I've been thinking more and more about how
the rise and increase in power of LLMs affects this choice.&lt;/p&gt;
&lt;p&gt;By definition, boring technology has been around for a long time. Piles of
content have been written and produced about it: tutorials, books, videos,
reference manuals, examples, blog posts and so on. All of this is consumed
during the LLM training process, making LLMs better and better at reasoning
about such technology.&lt;/p&gt;
&lt;p&gt;Conversely, &amp;quot;shiny technology&amp;quot; is new, and has much less material available. As
a result, LLMs won't be as familiar with it. This applies to many domains, but
one specific example for me personally is in the context of LaTeX.&lt;/p&gt;
&lt;p&gt;LaTeX certainly fits the &amp;quot;boring technology&amp;quot; bill. It's decades old, and has
been the mainstay of academic writing since the 1980s. When I used it for the
first time in 2002 (for a project report in my university AI class), it was
already very old. But people keep working on it and fixing issues; it's easy to
install and its wealth of capabilities and community size are staggering.
Moreover, people keep working &lt;em&gt;with&lt;/em&gt; it, producing more and more content and
examples the LLMs can ingest and learn from.&lt;/p&gt;
&lt;p&gt;I keep hearing about the advantages of new and shiny systems like
Typst. However, with the help of LLMs, almost none of the advantages seem
meaningful to me. LLMs are &lt;em&gt;great&lt;/em&gt; at LaTeX and help a lot with learning or
remembering the syntax, finding the right packages, deciphering errors and
even generating tedious parts like tables and charts, significantly reducing
the need for scripting &lt;a class="footnote-reference" href="#footnote-1" id="footnote-reference-1"&gt;[1]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can use LLMs either as standalone or fully integrated into your LaTeX
environment; Overleaf has a built-in AI helper, and for local editing you can
use VSCode plugins or other tools. I'm personally &lt;a class="reference external" href="https://eli.thegreenplace.net/2025/notes-on-using-latex-to-generate-formulae/"&gt;content with TeXstudio&lt;/a&gt;
and use LLMs as standalone help, but YMMV.&lt;/p&gt;
&lt;p&gt;There are many examples where boring technology and LLMs go well together. The
main criticism of boring technology is typically that it's &amp;quot;too big, full of
cruft, difficult to understand&amp;quot;. LLMs really help cutting through the learning
curve though, and all that &amp;quot;cruft&amp;quot; is very likely to become useful some time in
the future when you graduate from the basic use cases.&lt;/p&gt;
&lt;p&gt;To be clear: Typst looks really cool, and kudos to the team behind it! All I'm
saying in this post is that for me - personaly - the choice for now is to stick
with LaTeX as a &amp;quot;boring technology&amp;quot;.&lt;/p&gt;
&lt;div class="section" id="appendix-some-examples-of-llms-being-helpful-with-latex"&gt;
&lt;h2&gt;Appendix: some examples of LLMs being helpful with LaTeX&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;For finding the right math symbols, I rarely need to scan reference materials
any longer. LLMs will easily answer questions like &amp;quot;what's that squiggly
Greek letter used in math, and its latex symbol?&amp;quot; or &amp;quot;write the latex for
Green's theorem, integral form&amp;quot;.
For the trickiest / largest equations, LLMs are very good at &amp;quot;here's a picture
I took of my equation, give me its latex code&amp;quot; these days &lt;a class="footnote-reference" href="#footnote-2" id="footnote-reference-2"&gt;[2]&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;&amp;quot;Here's a piece of code and the LaTeX error I'm getting on it; what's wrong?&amp;quot;&lt;/p&gt;
&lt;p&gt;This is made more ergonomic by editor integrations, but I personally find that
LaTeX's error message problem is hugely overblown. 95% of the errors are
reasonably clear, and serious sleuthing is only rarely required in practice.
In that minority of cases, pasting some code and the error into a standalone
LLM isn't a serious time drain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Generating TikZ diagrams and plots. For this, the hardest part is getting
started and finding the right element names, and so on. It's very useful to
just ask an LLM to emit something initial and then tweak it manually later,
as needed. You can also ask the LLM to explain each thing it emits in
detail - this is a great learning tool for deeper understanding.&lt;/p&gt;
&lt;p&gt;Recently I had luck going &amp;quot;meta&amp;quot; with this: when the diagram has repetitive
elements, I may ask the LLM to &amp;quot;write a Python program that generates a TikZ
diagram ...&amp;quot;, and it works well.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Generating and populating tables, and converting them from other data
formats or screenshots.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Help with formatting and typesetting (how do I change margins to XXX and
spacing to YYY).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr class="docutils" /&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-1" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-1"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;p class="first"&gt;When it comes to scripting, I generally prefer sticking to real
programming languages anyway. If there's anything non-trivial to
auto-generate I wouldn't use a LaTeX macro, but would write a Python
program to generate whatever I need and embed it into the document
with something like &lt;tt class="docutils literal"&gt;\input{}&lt;/tt&gt;.&lt;/p&gt;
&lt;p class="last"&gt;Typst's scripting system may be marketed as &amp;quot;clean and powerful&amp;quot;, but
why learn yet another scripting language?&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-2" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-2"&gt;[2]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;p class="first"&gt;Ignoring LaTeX's equation notation and doing their own thing is one of
the biggest mistakes Typst makes, in my opinion. LaTeX's notation may
not be perfect, but it's near universal at this point with support in
almost all math-aware tools.&lt;/p&gt;
&lt;p class="last"&gt;Typst's math mode is a clear sign of the second system effect, and isn't
&lt;a class="reference external" href="https://laurmaedje.github.io/posts/math-mode-problem/"&gt;even stable&lt;/a&gt;.&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
</content><category term="misc"></category><category term="Math"></category><category term="Blogging"></category><category term="Software &amp; Tools"></category></entry></feed>