<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>Michał Brzozowski</title>
      <link>https://brzozo.ws</link>
      <description></description>
      <generator>Zola</generator>
      <language>en</language>
      <atom:link href="https://brzozo.ws/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Thu, 04 Sep 2025 00:00:00 +0000</lastBuildDate>
      <item>
          <title>How to fit a parabola to 3 points without solving a system of equations</title>
          <pubDate>Thu, 04 Sep 2025 00:00:00 +0000</pubDate>
          <author>Unknown</author>
          <link>https://brzozo.ws/fitting-parabola-to-3-points/</link>
          <guid>https://brzozo.ws/fitting-parabola-to-3-points/</guid>
          <description>&lt;p&gt;If you search for a metod to do this, all the results seem to be essentialy the same thing. Write a system of equations, subtract one from the others, solve the simplified system. There are however alternatives. &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Divided_differences&quot;&gt;Divided differences&lt;&#x2F;a&gt; comes up if you search hard enough or ask your favorite LLM, but the method I present doesn&#x27;t seem to be featured anywhere. It is certainly less computationally expensive than naively solving a system of equations, not that it would really matter ;)&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;python&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-python &quot;&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;def &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fa1b3;&quot;&gt;calculate_quadratic_coefficients_2&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;points&lt;&#x2F;span&gt;&lt;span&gt;):
&lt;&#x2F;span&gt;&lt;span&gt;    x1, y1 = points[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span&gt;    x2, y2 = points[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span&gt;    x3, y3 = points[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# We exploit the fact that polynomials are linear
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# in their coefficients to decompose a quadratic
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# into two polynomials that are easier to solve.
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# Fit a linear function to the endpoints.
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# We could use any pair, but it&amp;#39;s reasonable to choose
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# (x1,y1) and (x3,y3) for better numerical stability
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# (assuming x1&amp;lt;x2&amp;lt;x3).
&lt;&#x2F;span&gt;&lt;span&gt;    b = (y3-y1) &#x2F; (x3 - x1)
&lt;&#x2F;span&gt;&lt;span&gt;    c = y1 - b*x1
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# Reduce y2 by the linear polynomial
&lt;&#x2F;span&gt;&lt;span&gt;    y2 = y2 - b*x2 - c
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# Because reduction would cause the endpoints to equal 0, 
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# they&amp;#39;re roots of y = a(x-x1)(x-x3). Calculate a
&lt;&#x2F;span&gt;&lt;span&gt;    a = y2 &#x2F; ((x2-x1)*(x2-x3))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# We have a and two roots. This is 3 degrees of freedom
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# and is enough to calculate coefficients by rearranging
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# Vieta&amp;#39;s formulas. We also add back b and c 
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# from the linear function.
&lt;&#x2F;span&gt;&lt;span&gt;    b = -a *(x1+x3) + b
&lt;&#x2F;span&gt;&lt;span&gt;    c = a*x1*x3 + c
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;return &lt;&#x2F;span&gt;&lt;span&gt;a, b, c
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>OpenWrt - how to factory reset when firstboot fails</title>
          <pubDate>Fri, 30 Aug 2024 00:00:00 +0000</pubDate>
          <author>Unknown</author>
          <link>https://brzozo.ws/openwrt-factory-reset/</link>
          <guid>https://brzozo.ws/openwrt-factory-reset/</guid>
          <description>&lt;p&gt;Recently I dusted off a TP-Link Archer C5 v1.20 to make a Wi-Fi extender. But as luck would have it I couldn&#x27;t connect to its admin interface due to my previous tinkering. Thankfully OpenWrt offers a failsafe mode which runs with known settings and allows one to SSH into the box. To nuke all user configuration, you&#x27;re supposed to run &lt;code&gt;firstboot&lt;&#x2F;code&gt;. The idea is that all mutable configuration is stored as an &amp;quot;overlay&amp;quot; JFFS2 partition over the read-only SquashFS image. But in my case, &lt;code&gt;firstboot&lt;&#x2F;code&gt; did not format the JFFS2 partition. There was no output at all! The solution is to do it manually:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;cd &#x2F;overlay&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;rm -rf *
&lt;&#x2F;span&gt;&lt;span&gt;reboot
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will bring your router to a factory config.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Introducing random-osm-note</title>
          <pubDate>Wed, 27 Dec 2023 00:00:00 +0000</pubDate>
          <author>Unknown</author>
          <link>https://brzozo.ws/introducing-random-osm-note/</link>
          <guid>https://brzozo.ws/introducing-random-osm-note/</guid>
          <description>&lt;p&gt;Let&#x27;s kick off the blog with a project! &lt;a href=&quot;https:&#x2F;&#x2F;brzozo.ws&#x2F;random-note&#x2F;list&quot;&gt;random-osm-note&lt;&#x2F;a&gt; is a Flask-based project to help OSM mappers resolve the &lt;a href=&quot;https:&#x2F;&#x2F;resultmaps.neis-one.org&#x2F;osm-notes&quot;&gt;deluge&lt;&#x2F;a&gt; of unresolved Notes. Turns out many Notes don&#x27;t necessitate a personal visit to confirm the reported improvements. I found it quite addictive!&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>About</title>
          <pubDate>Sat, 14 Oct 2023 00:00:00 +0000</pubDate>
          <author>Unknown</author>
          <link>https://brzozo.ws/about/</link>
          <guid>https://brzozo.ws/about/</guid>
          <description>&lt;ul&gt;
&lt;li&gt;Analog IC design engineer.&lt;&#x2F;li&gt;
&lt;li&gt;Based in Gdynia, Poland.&lt;&#x2F;li&gt;
&lt;li&gt;FOSS and maps enjoyer.&lt;&#x2F;li&gt;
&lt;li&gt;Check out links above.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
    </channel>
</rss>
