<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>teaching | Mohammad Moshtaghi</title>
    <link>https://mhmmoshtaghi.github.io/category/teaching/</link>
      <atom:link href="https://mhmmoshtaghi.github.io/category/teaching/index.xml" rel="self" type="application/rss+xml" />
    <description>teaching</description>
    <generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><copyright>© 2023 Mohammad Moshtaghi</copyright><lastBuildDate>Tue, 30 Nov 2021 11:57:40 -0700</lastBuildDate>
    <image>
      <url>https://mhmmoshtaghi.github.io/media/logo_hu1dc8deb1865675db905a286e8af9308b_16380_300x300_fit_lanczos_3.png</url>
      <title>teaching</title>
      <link>https://mhmmoshtaghi.github.io/category/teaching/</link>
    </image>

    <item>
      <title>Elegant Derivatives of Large Products</title>
      <link>https://mhmmoshtaghi.github.io/post/elegant-derivatives-of-large-products/</link>
      <pubDate>Tue, 30 Nov 2021 11:57:40 -0700</pubDate>
      <guid>https://mhmmoshtaghi.github.io/post/elegant-derivatives-of-large-products/</guid>
      <description>&lt;p&gt;An ongoing research project on modeling computer security has thrown me back into calculus for the first time since my undergraduate differential equations course in 2014, which as an aside was the only college course that forced me to buy the professor&amp;rsquo;s custom textbook just to get access to homework problems.
(I&amp;rsquo;m still mad about that.)
Anyway, my research led me to take the derivative of an expression of the form:&lt;/p&gt;
&lt;p&gt;$$\prod_{i=1}^n f_i(x)$$&lt;/p&gt;
&lt;p&gt;For the uninitiated, $\prod$ is a mathematical symbol meaning &amp;ldquo;product&amp;rdquo; (and is analogous to the $\sum$ symbol meaning &amp;ldquo;sum&amp;rdquo;).
It says to look at each $f_i$ term as $i$ goes from $1, 2, \ldots, n$ and multiply them all together:&lt;/p&gt;
&lt;p&gt;$$\prod_{i=1}^n f_i(x) = f_1(x) \times f_2(x) \times \cdots \times f_n(x)$$&lt;/p&gt;
&lt;p&gt;Taking this derivative is something high-school me was much better prepared for than current postdoc me, but after some head scratching I found the elegant solution:&lt;/p&gt;
&lt;p&gt;$$\frac{d}{dx} \prod_{i=1}^n f_i(x) = \prod_{i=1}^n f_i(x) \cdot \sum_{i=1}^n \frac{f_i&#39;(x)}{f_i(x)}$$&lt;/p&gt;
&lt;p&gt;As is common in mathematics, there&amp;rsquo;s a direct but tedious way to get this answer and another more elegant way to get the same thing.
I&amp;rsquo;m not the first to derive this solution, but I&amp;rsquo;m writing it up for posterity because I will inevitably forget this trick in a few days.
A PDF of the two derivations without all the handholding I&amp;rsquo;m about to do is available &lt;a href=&#34;https://mhmmoshtaghi.github.io/uploads/elegant-derivatives-of-large-products.pdf&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;method-1-product-rule&#34;&gt;Method 1: Product Rule&lt;/h2&gt;
&lt;p&gt;I had to sweep away years of mental cobwebs to remember the &lt;a href=&#34;https://en.wikipedia.org/wiki/Product_rule&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;product rule&lt;/a&gt; for derivatives.
My expression is a product, after all, so why not start there?
The product rule states:&lt;/p&gt;
&lt;p&gt;$$\frac{d}{dx}(u \cdot v) = u&#39; \cdot v + u \cdot v&#39;$$&lt;/p&gt;
&lt;p&gt;This works for the product of two terms, but $\prod_{i=1}^n f_i(x)$ has $n$ terms.
Let&amp;rsquo;s try peeling off terms one-by-one, starting with $f_1(x)$, and then applying the product rule.&lt;/p&gt;
&lt;p&gt;$$\begin{align*}
\frac{d}{dx} \prod_{i=1}^n f_i(x) &amp;amp;= \frac{d}{dx} \left(f_1(x) \cdot \prod_{i=2}^n f_i(x)\right) \\
&amp;amp;= f_1&#39;(x) \cdot \prod_{i=2}^n f_i(x) + f_1(x) \cdot \frac{d}{dx} \left(\prod_{i=2}^n f_i(x)\right)
\end{align*}$$&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s progress, but now we have to repeat the process to deal with the $\frac{d}{dx} \left(\prod_{i=2}^n f_i(x)\right)$ term, peeling off $f_2(x)$ and applying the product rule again:&lt;/p&gt;
&lt;p&gt;$$\begin{align*}
\frac{d}{dx} \prod_{i=1}^n f_i(x) &amp;amp;= f_1&#39;(x) \cdot \prod_{i=2}^n f_i(x) + f_1(x) \cdot \frac{d}{dx} \left(\prod_{i=2}^n f_i(x)\right) \\
&amp;amp;= f_1&#39;(x) \cdot \prod_{i=2}^n f_i(x) + f_1(x) \\
&amp;amp;\quad \cdot \left(f_2&#39;(x) \cdot \prod_{i=3}^n f_i(x) + f_2(x) \cdot \frac{d}{dx} \left(\prod_{i=3}^n f_i(x)\right)\right)
\end{align*}$$&lt;/p&gt;
&lt;p&gt;This expression&amp;rsquo;s going to have &lt;a href=&#34;https://media.giphy.com/media/22eVpVYpRhaE0/giphy.gif&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;more layers than an ogre&lt;/a&gt;!
If we were to do the peel-and-product rule strategy $n-1$ times, we would arrive at:&lt;/p&gt;
&lt;p&gt;$$\begin{align*}
\frac{d}{dx} \prod_{i=1}^n f_i(x) &amp;amp;= f_1&#39;(x) \cdot \prod_{i=2}^n f_i(x) + f_1(x) \\
&amp;amp;\quad \cdot \left(f_2&#39;(x) \cdot \prod_{i=3}^n f_i(x) + f_2(x) \right. \\
&amp;amp;\quad \cdot \left(f_3&#39;(x) \cdot \prod_{i=4}^n f_i(x) + f_3(x) \cdots + f_{n-2}(x) \right. \\
&amp;amp;\quad \left. \left. \cdot \left(f_{n-1}&#39;(x) \cdot f_n(x) + f_n&#39;(x) \cdot f_{n-1}(x)\right) \cdots \right) \right)
\end{align*}$$&lt;/p&gt;
&lt;p&gt;Do you see the pattern?
If we distribute the $f_i(x)$ terms at the end of each of the lines above into the parentheses that immediately follow,&lt;/p&gt;
&lt;p&gt;$$\begin{align*}
\frac{d}{dx} \prod_{i=1}^n f_i(x) &amp;amp;= f_1&#39;(x) \cdot \prod_{i=2}^n f_i(x) + f_2&#39;(x) \cdot f_1(x) \cdot \prod_{i=3}^n f_i(x) \\
&amp;amp;\quad + f_3&#39;(x) \cdot f_1(x) \cdot f_2(x) \cdot \prod_{i=4}^n f_i(x) \\
&amp;amp;\quad + f_{n-1}&#39;(x) \cdot f_1(x) \cdots f_{n-2}(x) \cdot f_n(x) \\
&amp;amp;\quad + f_n&#39;(x) \cdot f_1(x) \cdots f_{n-1}(x)
\end{align*}$$&lt;/p&gt;
&lt;p&gt;We&amp;rsquo;re adding up a bunch of terms, each of which is a derivative $f_i&#39;(x)$ multiplied by all the other $f_j(x)$&amp;rsquo;s, where $j \neq i$.
Landing this messy, notation-heavy plane, we can rewrite this long sum as&lt;/p&gt;
&lt;p&gt;$$\frac{d}{dx} \prod_{i=1}^n f_i(x) = \sum_{i=1}^n f_i&#39;(x) \cdot \frac{\prod_{j=1}^n f_j(x)}{f_i(x)}
= \prod_{i=1}^n f_i(x) \cdot \sum_{i=1}^n \frac{f_i&#39;(x)}{f_i(x)},$$&lt;/p&gt;
&lt;p&gt;which is the solution we came for.&lt;/p&gt;
&lt;h2 id=&#34;method-2-leveraging-logarithms&#34;&gt;Method 2: Leveraging Logarithms&lt;/h2&gt;
&lt;p&gt;Mathematicians crave elegance, and Method 1 wasn&amp;rsquo;t that.
We had to keep keen eyes out for patterns as they emerged and carefully distribute/rearrange many terms to get the solution.
This second method will be much cleaner, but as many clever methods do, it begins with an unintuitive step.&lt;/p&gt;
&lt;p&gt;Let $F(x) = \prod_{i=1}^n f_i(x)$.
Taking the &lt;a href=&#34;https://en.wikipedia.org/wiki/Natural_logarithm&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;natural logarithm&lt;/a&gt; of both sides,&lt;/p&gt;
&lt;p&gt;$$\ln(F(x)) = \ln\left(\prod_{i=1}^n f_i(x)\right) = \sum_{i=1}^n \ln(f_i(x)),$$&lt;/p&gt;
&lt;p&gt;where the last equality follows from the fact that the logarithm of a product is equal to the sum of logarithms.
The derivative of the natural logarithm is:&lt;/p&gt;
&lt;p&gt;$$\frac{d}{dx}\ln(x) = \frac{1}{x}$$&lt;/p&gt;
&lt;p&gt;Using &lt;a href=&#34;https://en.wikipedia.org/wiki/Chain_rule&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;chain rule&lt;/a&gt; to take the derivative of both sides of the above equality,&lt;/p&gt;
&lt;p&gt;$$\begin{align*}
\frac{d}{dx}\ln(F(x)) &amp;amp;= \frac{d}{dx}\sum_{i=1}^n \ln(f_i(x)) \\
\frac{1}{F(x)} \cdot \frac{dF}{dx} &amp;amp;= \sum_{i=1}^n \frac{1}{f_i(x)} \cdot f_i&#39;(x) \\
\frac{dF}{dx} &amp;amp;= F(x) \cdot \sum_{i=1}^n \frac{f_i&#39;(x)}{f_i(x)}
\end{align*}$$&lt;/p&gt;
&lt;p&gt;If we plug $F(x) = \prod_{i=1}^n f_i(x)$ back in, out pops the solution:&lt;/p&gt;
&lt;p&gt;$$\frac{d}{dx} \prod_{i=1}^n f_i(x) = \prod_{i=1}^n f_i(x) \cdot \sum_{i=1}^n \frac{f_i&#39;(x)}{f_i(x)}$$&lt;/p&gt;
&lt;h2 id=&#34;concluding-thoughts&#34;&gt;Concluding Thoughts&lt;/h2&gt;
&lt;p&gt;Having initially stumbled upon Method 1, I was surprised that this derivative came out so beautifully in the end.
Credit where it&amp;rsquo;s due: I adapted the elegant Method 2 from &lt;a href=&#34;https://www.quora.com/What-is-the-first-derivative-of-an-infinite-product-of-factors&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this post&lt;/a&gt; regarding infinite products.
I have some technical notes at the end of the &lt;a href=&#34;https://mhmmoshtaghi.github.io/uploads/elegant-derivatives-of-large-products.pdf&#34; target=&#34;_blank&#34;&gt;linked PDF&lt;/a&gt; about when Method 2 breaks down, though I believe Method 1 does not have any of these problems.&lt;/p&gt;
&lt;p&gt;Hopefully this was fun (and if it wasn&amp;rsquo;t, I doubt you read this far 😉).
This is one of many examples in mathematics of finding multiple solutions to the same problem and learning something different each time.
Next time you emerge victorious from a tedious derivation, see if you can find a clever alternative!&lt;/p&gt;
</description>
    </item>

    <item>
      <title>Pool Testing is k-ary Search for COVID-19</title>
      <link>https://mhmmoshtaghi.github.io/post/pool-testing-is-kary-search/</link>
      <pubDate>Thu, 09 Jul 2020 14:04:44 -0700</pubDate>
      <guid>https://mhmmoshtaghi.github.io/post/pool-testing-is-kary-search/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve seen a handful of articles in the last week about &lt;em&gt;pool testing&lt;/em&gt; and &lt;em&gt;sample pooling&lt;/em&gt; for COVID-19.
The gist of this technique is simple: to make our limited supply of test kits (reagents) stretch farther, mix several people&amp;rsquo;s samples together and then test the mixture for COVID-19.
Ideally, if the test comes back negative, everyone in that &amp;ldquo;sample pool&amp;rdquo; could be declared COVID-free using just one test.
Otherwise, if the mixture comes back positive, then additional tests are needed to find the individual positive samples.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m far from a public health and epidemiology expert, but as an enthusiastic computer scientist I can&amp;rsquo;t help but see &lt;em&gt;binary search&lt;/em&gt; (or more generally, $k$-ary search) all over this pool testing technique.
My goal in this post is to draw out this connection, illustrating why the efficiency of $k$-ary search (and of pool testing, by extension) is so attractive.
I&amp;rsquo;ll also do some crude math to explore what happens to pool testing if there are too many infections in the population and how many tests it could actually save.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re not interested in any of that but want to know more about pool testing, NPR has a &lt;a href=&#34;https://www.npr.org/sections/health-shots/2020/07/06/886886255/pooling-coronavirus-tests-can-spare-scarce-supplies-but-theres-a-catch&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;short primer&lt;/a&gt; and the FDA has put out a &lt;a href=&#34;https://www.fda.gov/news-events/press-announcements/coronavirus-covid-19-update-facilitating-diagnostic-test-availability-asymptomatic-testing-and&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;statement&lt;/a&gt; on the topic.
On the other hand, if you&amp;rsquo;re interested in more serious research on the topic, this footnote&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; is for you.&lt;/p&gt;
&lt;h2 id=&#34;finding-things-fast&#34;&gt;Finding Things Fast&lt;/h2&gt;
&lt;p&gt;In a &lt;em&gt;search problem&lt;/em&gt;, the goal is to find a specific item $x^*$ amidst a whole bunch of possibilities $(x_1, x_2, \ldots, x_n)$.
It&amp;rsquo;s like &lt;a href=&#34;https://waldo.fandom.com/wiki/Waldo_Wiki&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Where&amp;rsquo;s Waldo&lt;/a&gt; if Waldo were $x^*$ and each $x_i$ was a person on the page.
Or, perhaps more practically, it&amp;rsquo;s the way you give your favorite maps app a specific address $x^*$ and it has to find that place&amp;rsquo;s data (latitude/longitude, reviews, etc.) amongst all possible places $x_i$ in its gigantic database.&lt;/p&gt;
&lt;p&gt;A not-so-great approach to playing Where&amp;rsquo;s Waldo is to make a list of every person on the page and check them one-by-one to see if they&amp;rsquo;re Waldo.
(This is, perhaps, an entertaining way to play since you get to appreciate all the fun and ridiculous details, but we&amp;rsquo;re going for efficiency here).
In computer science, we call this strategy — or &amp;ldquo;algorithm&amp;rdquo; — &lt;em&gt;brute force search&lt;/em&gt;: when all else fails, just try everything.
How bad can this be?
Well, in the worst case Waldo might be the very last person in our list, so we would have had to check all $n$ people before we found him.
So, knowing that the least clever search strategy makes us try $n$ times before we find Waldo, can we do better?&lt;/p&gt;
&lt;p&gt;Imagine that you have a friend who already knows where Waldo is and has agreed to help you out by telling you which half of the page he&amp;rsquo;s on (left or right).
Now you only have to search half of the possibilities, or roughly $n/2$ people.
Say your friend&amp;rsquo;s really helpful, and they&amp;rsquo;ll let you do this as many times as you want: they&amp;rsquo;ll keep telling you which half of the remaining section Waldo&amp;rsquo;s in until you find him.
So at first you have $n$ people to look through, then after your friend helps once you have $n/2$, and after helping again you have $n/4$, and then $n/8$, and so on.
In general, if your friend has helped you $i$ times, then you only have $n/(2^i)$ people to look through.
Doing a little algebra, after your friend has helped you $\log_2(n)$ times, you only have $n/(2^{\log_2(n)}) = n/n = 1$ person left, and that person is Waldo.
This strategy is &lt;em&gt;binary search&lt;/em&gt;: &amp;ldquo;binary&amp;rdquo; because your friend splits the possibilities in two each time they help.&lt;/p&gt;
&lt;p&gt;It may have been a while since you&amp;rsquo;ve brushed up on your logarithms, so let&amp;rsquo;s look at some numbers to get a sense of how fast this is. An average Where&amp;rsquo;s Waldo puzzle has roughly $n = 500$ people on it.
So, if we were to use brute force search, we&amp;rsquo;d be looking through all $n = 500$ people.
However, if we had our helpful friend to do binary search with us, we&amp;rsquo;d only need to ask their help $\log_2(500) \approx 9$ times before we found Waldo!
Not bad, hey?&lt;/p&gt;
&lt;p&gt;The key to binary search is in throwing away whole chunks of possibilities all at once, rapidly narrowing our search field.
$k$-ary search is just a generalization, where instead of splitting the possibilities in half each time, we split them into $k$ equal parts. We then keep the $n/k$-sized section containing our target and repeat, requiring a total of $\log_k(n)$ search operations to find our target (which is even faster than binary search!). Before we call it quits with Waldo and get back to pool testing, it&amp;rsquo;s worth pointing out that there are plenty of ways to make searching even faster (especially with parallel algorithms). There are even search algorithms &lt;a href=&#34;http://www.randalolson.com/2015/02/03/heres-waldo-computing-the-optimal-search-strategy-for-finding-waldo/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;specifically for finding Waldo&lt;/a&gt;, if that&amp;rsquo;s your jam.&lt;/p&gt;
&lt;h2 id=&#34;pool-testing-meet-k-ary-search&#34;&gt;Pool Testing, Meet k-ary Search&lt;/h2&gt;
&lt;p&gt;Shifting our perspective on testing from personal experience (&amp;ldquo;Have I contracted COVID-19?&amp;quot;) to the population level (&amp;ldquo;Who in our communities are positive?&amp;quot;), we can frame testing as a search problem.
Among all individuals $(x_1, x_2, \ldots, x_n)$, we want to find those $x_i$&amp;rsquo;s that are positive for COVID-19 so they can isolate and get timely medical care.
In this setting, brute force search would be individually testing every single person — and that&amp;rsquo;s &lt;a href=&#34;https://www.nytimes.com/2020/07/06/us/coronavirus-test-shortage.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;way more tests&lt;/a&gt; than we have.
The current US strategy of only testing symptomatic cases isn&amp;rsquo;t more &amp;ldquo;efficient&amp;rdquo; than brute force, it&amp;rsquo;s just brute force search on a (hopefully) small subset of the total population.&lt;/p&gt;
&lt;p&gt;Pool testing, on the other hand, is similar to $k$-ary search.
Just like our helpful friend telling us which half of the page Waldo isn&amp;rsquo;t on, a single pool test ideally shows us a whole group of people that we can declare COVID-19 negative; in our search for positive cases, we can look elsewhere.&lt;/p&gt;














&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img alt=&#34;&#34; srcset=&#34;
               /post/pool-testing-is-kary-search/pooltest_hub8d5ccf727d58e61b91e4b04452d5a8c_507898_d893c5c675f1faec887bbbea523952bc.png 400w,
               /post/pool-testing-is-kary-search/pooltest_hub8d5ccf727d58e61b91e4b04452d5a8c_507898_a6fd6dae15544600ded74901ce065f67.png 760w,
               /post/pool-testing-is-kary-search/pooltest_hub8d5ccf727d58e61b91e4b04452d5a8c_507898_1200x1200_fit_lanczos_3.png 1200w&#34;
               src=&#34;https://mhmmoshtaghi.github.io/post/pool-testing-is-kary-search/pooltest_hub8d5ccf727d58e61b91e4b04452d5a8c_507898_d893c5c675f1faec887bbbea523952bc.png&#34;
               width=&#34;760&#34;
               height=&#34;353&#34;
               loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;p&gt;Consider the situation depicted above, with $128$ total individuals needing tests but only $4$ of them COVID-19 positive (shown in red).
If we tested all $128$ people individually (brute force), we would need $128$ tests.
But suppose we could reliably test pools of up to $16$ people at once, as shown in the first row.
Only three of the $128/16 = 8$ pool tests would come back positive, allowing us to immediately rule out $5 \times 16 = 80$ negative individuals.
For the three positive pools, we need to do additional tests to find the positive cases.
This could be done by individually testing everyone in the positive pools&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; — effectively using smaller brute force — requiring $3 \times 16 = 48$ additional tests.
Alternatively (assuming we had enough samples), we could do pool testing again, this time on smaller pools.&lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
So long as there aren&amp;rsquo;t too many positive samples (something we&amp;rsquo;ll revisit shortly), this will help us save on tests: in the picture, we only end up needing $30$ additional tests to handle the $48$ individuals in positive pools.
The table below compares the number of tests used by each testing strategy in this example, along with the number of samples per person required.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Testing Strategy&lt;/th&gt;
&lt;th&gt;Tests Used&lt;/th&gt;
&lt;th&gt;Tests Saved&lt;/th&gt;
&lt;th&gt;Samples per Person&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Individual (brute force)&lt;/td&gt;
&lt;td&gt;$128$&lt;/td&gt;
&lt;td&gt;$0\%$&lt;/td&gt;
&lt;td&gt;$1$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pool Testing (one round)&lt;/td&gt;
&lt;td&gt;$56$&lt;/td&gt;
&lt;td&gt;$56\%$&lt;/td&gt;
&lt;td&gt;$1$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pool Testing (repeated)&lt;/td&gt;
&lt;td&gt;$38$&lt;/td&gt;
&lt;td&gt;$70\%$&lt;/td&gt;
&lt;td&gt;$&amp;gt; 1$&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&#34;what-can-go-wrong&#34;&gt;What Can Go Wrong?&lt;/h2&gt;
&lt;p&gt;At least a few serious things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Added logistical complications for labs, including tracking which individuals&#39; samples are in which pools, added mixing steps, etc.&lt;/li&gt;
&lt;li&gt;The possibility of larger &lt;em&gt;false-negative&lt;/em&gt; rates (i.e., testing negative when the sample was, in fact, positive) due to samples getting diluted when they&amp;rsquo;re mixed into pools.&lt;sup id=&#34;fnref:4&#34;&gt;&lt;a href=&#34;#fn:4&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
&lt;li&gt;A loss of efficiency when there are too many positive samples.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the rest of this post, I&amp;rsquo;m going to focus on that last problem.
Pool testing&amp;rsquo;s strength lies in its ability to rule out large groups of negative cases at once, as we saw in the example.
But with too many positive cases, the likelihood of pools testing positive becomes much higher, requiring a greater number of subsequent tests.
At what point does pool testing end up using more tests than if we just tested everyone individually?&lt;/p&gt;
&lt;p&gt;Instead of repeated pool testing (like in our example above), consider the more practical protocol of doing only one round of pool testing and then testing all samples in positive pools individually.
If we have $n$ total samples, our pool size is $p$, and $x$ pool tests come back positive, then we will use a total of $n/p + xp$ tests: $n/p$ pool and $xp$ individual.
Since we&amp;rsquo;d use $n$ tests doing brute force, pool testing only saves us tests if $n/p + xp &amp;lt; n$, or equivalently, if:
$$x &amp;lt; (n/p)(1 - 1/p)$$&lt;/p&gt;
&lt;p&gt;To connect the number of positive pools $x$ we&amp;rsquo;ll have based on how many positive cases are in the population, let $r$ be the probability that any given sample is COVID-19 positive.
The probability that a pool of size $p$ contains a positive sample is $1 - (1 - r)^p$.
There are $n/p$ total pools, so the expected (average) number of positive pools is:
$$E[x] = (n/p)(1 - (1 - r)^p)$$
Therefore, we save on tests using pool testing in expectation if:
$$\begin{align*} (n/p)(1 - (1 - r)^p) &amp;amp;&amp;lt; (n/p)(1 - 1/p) \\ r &amp;amp;&amp;lt; 1 - p^{-1/p} \end{align*}$$&lt;/p&gt;














&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img alt=&#34;&#34; srcset=&#34;
               /post/pool-testing-is-kary-search/efficientplot_hubbab132a171178a63e8c403eaeaedda1_112102_95bee3cac31fd27c744668969647b2bf.png 400w,
               /post/pool-testing-is-kary-search/efficientplot_hubbab132a171178a63e8c403eaeaedda1_112102_bc08555fd46905af4750f157cfdc0c66.png 760w,
               /post/pool-testing-is-kary-search/efficientplot_hubbab132a171178a63e8c403eaeaedda1_112102_1200x1200_fit_lanczos_3.png 1200w&#34;
               src=&#34;https://mhmmoshtaghi.github.io/post/pool-testing-is-kary-search/efficientplot_hubbab132a171178a63e8c403eaeaedda1_112102_95bee3cac31fd27c744668969647b2bf.png&#34;
               width=&#34;760&#34;
               height=&#34;570&#34;
               loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;p&gt;The above graph plots this efficient region.
The x-axis is the pool size $p$ and the y-axis is the infection rate $r$.
Any point in the blue region represents a $(p,r)$ pair for which pool testing uses less tests than brute force in expectation.
For example, with a pool size of $p = 16$, our crude math suggests that pool testing is more efficient for infection rates up to, coincidentally, $r \approx 16\%$.
This would be a terrifyingly high infection rate (at the time of this writing, the CDC reports a $\approx 1\%$ &lt;a href=&#34;https://www.cdc.gov/covid-data-tracker/#cases&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;positive case rate&lt;/a&gt; in the US), so it seems that in realistic settings even one round of pool testing would save a lot of tests.&lt;/p&gt;
&lt;h2 id=&#34;taking-our-savings-to-the-bank&#34;&gt;Taking Our Savings to the Bank&lt;/h2&gt;
&lt;p&gt;To recap, we&amp;rsquo;ve seen how pool testing is related to $k$-ary search, how both of these techniques leverage the ability to rule out large groups of possibilities to narrow things down quickly, and how pool testing will save us tests so long as the infection rate is low enough.
The last thing to nail down is how many tests are actually saved.
From our work above, we know that the expected number of tests saved using one round of pool testing is:
$$\begin{align*} E[\text{# tests saved}] &amp;amp;= \text{# tests for brute force} - E[\text{# tests for pool testing}] \\ &amp;amp;= n - (n/p + E[\text{# positive pools}] \cdot p) \\ &amp;amp;= n - n/p - (n/p)(1 - (1-r)^p)p \\ &amp;amp;= n(-1/p + (1-r)^p) \end{align*}$$
The fraction of tests saved is just the number of tests saved divided by $n$, so a single round of pool testing in pools of size $p$ uses a $(1-r)^p - 1/p$ fraction less tests.
The following plot shows this equation for different pool sizes $p$ as a function of the infection rate $r$.&lt;/p&gt;














&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img alt=&#34;&#34; srcset=&#34;
               /post/pool-testing-is-kary-search/savingsplot_hu0b73f0fe4a2adce77317aafa0603f92a_185079_8566ec12e810fe007a61095c9a21c56e.png 400w,
               /post/pool-testing-is-kary-search/savingsplot_hu0b73f0fe4a2adce77317aafa0603f92a_185079_f3c789c9a66a37ba6b4ac7c12ab8f208.png 760w,
               /post/pool-testing-is-kary-search/savingsplot_hu0b73f0fe4a2adce77317aafa0603f92a_185079_1200x1200_fit_lanczos_3.png 1200w&#34;
               src=&#34;https://mhmmoshtaghi.github.io/post/pool-testing-is-kary-search/savingsplot_hu0b73f0fe4a2adce77317aafa0603f92a_185079_8566ec12e810fe007a61095c9a21c56e.png&#34;
               width=&#34;760&#34;
               height=&#34;570&#34;
               loading=&#34;lazy&#34; data-zoomable /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;p&gt;This shows that larger pool sizes have the potential for saving more tests, but also degrade in their efficiency more rapidly as the infection rate $r$ grows.
Eventually, if the infection rate becomes too large, all four curves become negative and pool testing ends up using more tests than brute force.
This corresponds to leaving the efficient region shown in the previous graph.
If you&amp;rsquo;re having a hard time interpreting these curves, the following table compares pool testing with $p = 4$ (blue) and $p = 16$ (green).&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pool Size&lt;/th&gt;
&lt;th&gt;Tests Saved at $r = 1\%$&lt;/th&gt;
&lt;th&gt;Tests Saved at $r = 5\%$&lt;/th&gt;
&lt;th&gt;Infection Rate for No Savings&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;$p = 4$&lt;/td&gt;
&lt;td&gt;$71\%$&lt;/td&gt;
&lt;td&gt;$56\%$&lt;/td&gt;
&lt;td&gt;$r = 29\%$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$p = 16$&lt;/td&gt;
&lt;td&gt;$79\%$&lt;/td&gt;
&lt;td&gt;$38\%$&lt;/td&gt;
&lt;td&gt;$r = 16\%$&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The key takeaway is that from a purely test-savings perspective, pool testing does a remarkable job for any reasonable pool size.
While it is true that pool testing can end up using more tests than traditional testing if the infection rate grows too large, my crude math suggests that the infection rate would need to be quite high ($r &amp;gt; 10\%$) before this inefficiency would be noticeable.
At today&amp;rsquo;s US infection rate of $r \approx 1\%$, we could be $70\%$ more efficient with our limited supply of testing reagents, helping more people get tested more often.
Perhaps if this technique were widely used, we would all be that much closer to safely getting on with our lives.&lt;/p&gt;
&lt;section class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://jamanetwork.com/journals/jamanetworkopen/fullarticle/2767513&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Cherif et al. 2020&lt;/a&gt; detail a recent mathematical model for pool testing and &lt;a href=&#34;https://academic.oup.com/cid/article/doi/10.1093/cid/ciaa531/5828059&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Yelin et al. 2020&lt;/a&gt; characterize its dilution and false-negative rates. The references in the Yelin paper also cover deeper mathematical analysis (e.g., &lt;a href=&#34;https://projecteuclid.org/euclid.aoms/1177731363&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Dorfman 1943&lt;/a&gt;) and how pool testing has been used to combat infectious disease in the past (e.g., for malaria in &lt;a href=&#34;https://jcm.asm.org/content/48/2/512&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Taylor et al. 2010&lt;/a&gt;).&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;From my brief sifting of the literature, practical implementations of pool testing only use one round of pool tests: roughly $65\%$ of each sample is used in a pool test, and the remaining $35\%$ is saved for an individual test in case the pool comes back positive. Repeated pool testing doesn&amp;rsquo;t seem to be used in practice, presumably because it would rely on collecting additional swab samples per person.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:3&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;I&amp;rsquo;ve depicted the subpool tests in a &lt;em&gt;binary&lt;/em&gt; search kind of way where each positive pool is split in &lt;em&gt;half&lt;/em&gt; and retested, but they could be broken into any number of groups.&amp;#160;&lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:4&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://academic.oup.com/cid/article/doi/10.1093/cid/ciaa531/5828059&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Yelin et al. 2020&lt;/a&gt; estimate that the false-negative rates for pools as large as $16$ or $32$ is roughly $10\%$ based on their experiments. I chose not to do my speculative math for dilution and false-negative rates because I don&amp;rsquo;t understand how PCR tests actually work and don&amp;rsquo;t believe in blindly oversimplifying things for the sake of nice math.&amp;#160;&lt;a href=&#34;#fnref:4&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</description>
    </item>

    <item>
      <title>Solving the Molecube by Reduction</title>
      <link>https://mhmmoshtaghi.github.io/post/solving-the-molecube-by-reduction/</link>
      <pubDate>Mon, 06 Jan 2020 13:00:00 -0700</pubDate>
      <guid>https://mhmmoshtaghi.github.io/post/solving-the-molecube-by-reduction/</guid>
      <description>&lt;p&gt;My sister-in-law surprised me with a &lt;a href=&#34;http://www.recenttoys.com/meffert-molecube-twister-puzzle/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Molecube&lt;/a&gt; for Christmas, which combines the logic of a Sudoku puzzle with the mechanics of a Rubik&amp;rsquo;s cube. Each ball on the Molecube is one of nine colors, and the goal is to reconfigure a shuffled Molecube so each of its faces has all nine colors on it.&lt;/p&gt;














&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img src=&#34;http://www.recenttoys.com/wp-content/uploads/2019/11/meffert-molecube-twister-puzzle-1200x900.jpg&#34; alt=&#34;&#34; loading=&#34;lazy&#34; data-zoomable width=&#34;65%&#34; /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;p&gt;It turns out that solving the Molecube is a wonderful exercise in what computer scientists call &lt;em&gt;reduction&lt;/em&gt;, which involves transforming a problem we don&amp;rsquo;t know how to solve into one that we do, solving that version, and then translating the solution back into the original problem. In this post, I&amp;rsquo;ll give a reader-friendly primer on reduction, outline a reduction from the Molecube to the Rubik&amp;rsquo;s cube, and then wrap up by solving the Molecube with a standard Rubik&amp;rsquo;s cube algorithm.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re interested in solving the Molecube yourself (and perhaps you&amp;rsquo;re here looking for hints), I&amp;rsquo;ve created a &lt;a href=&#34;https://mhmmoshtaghi.github.io/files/molecube_worksheet.pdf&#34; target=&#34;_blank&#34;&gt;worksheet&lt;/a&gt; you can use and will point out when you should skip ahead in the post so as to avoid spoiling this delightful puzzle.&lt;/p&gt;
&lt;h2 id=&#34;reduction-there-and-back-again&#34;&gt;Reduction: There and Back Again&lt;/h2&gt;
&lt;p&gt;Say we have a problem $A$ that we don&amp;rsquo;t know how to solve and another problem $B$ that we do know how to solve. Said another way, we have an &amp;ldquo;algorithm&amp;rdquo; that can answer any question asked in the form of problem $B$, but we have no such algorithm for problem $A$ questions. The whole idea of reduction is to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Take a problem $A$ question (which we don&amp;rsquo;t know how to answer) and &amp;ldquo;transform&amp;rdquo; it into a problem $B$ question (which we do know how to answer).&lt;/li&gt;
&lt;li&gt;Use the &amp;ldquo;algorithm&amp;rdquo; for problem $B$ questions to get an answer for our transformed problem $A$ question.&lt;/li&gt;
&lt;li&gt;Translate the algorithm&amp;rsquo;s answer back into the context of problem $A$.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That&amp;rsquo;s it. We use a known algorithm (for problem $B$) as our workhorse for a new and unknown problem (problem $A$), and out pop solutions for our unknown problem! This powerful technique underlies almost all of theoretical computer science, giving us a tool to relate difficult problems to one another (as opposed to treating every new problem as something totally unique). I recently heard a high-profile professor in Computer Science claim that reduction is one of only two truly new ideas our discipline has ever contributed to science (though she called this idea &amp;ldquo;hierarchy&amp;rdquo;, with the other idea being &amp;ldquo;abstraction&amp;rdquo;).&lt;/p&gt;
&lt;p&gt;A natural question to ask next would be if all problems can be tackled with reduction. Unfortunately, in practice, finding the right translation between a pair of problems (Step 1, above) can be prohibitively difficult. Reduction is easiest when the two problems seem to have an obvious relationship we can exploit, which brings us to the Molecube and the Rubik&amp;rsquo;s cube.&lt;/p&gt;
&lt;h2 id=&#34;a-sudoku-like-transformation&#34;&gt;A Sudoku-Like Transformation&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s difficult to overstate how much of the Molecube&amp;rsquo;s solution is given away in its advertising as &amp;ldquo;Sudoku + Rubik&amp;rsquo;s cube&amp;rdquo;. My solution will treat this equation quite literally, starting with a transformation that relies on a Sudoku puzzle. I found this transformation by asking two simple questions:&lt;/p&gt;
&lt;img src=&#34;shuffled.png&#34; style=&#34;display: inline-block; width: 48%; margin-right: 2%&#34;/&gt;
&lt;img src=&#34;rubiks-cube.jpg&#34; style=&#34;display: inline-block; width: 46%; margin-left: 2%&#34;/&gt;
&lt;ol&gt;
&lt;li&gt;How are the Molecube and the Rubik&amp;rsquo;s cube similar?&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;They&amp;rsquo;re both 3x3x3 cubes, meaning they both have 6 faces, 8 corners, and 12 edges. This totals 26 balls (on the Molecube) or blocks (on the Rubik&amp;rsquo;s cube).&lt;/li&gt;
&lt;li&gt;Their physical mechanics (spinning, twisting, etc.) are identical.&lt;/li&gt;
&lt;li&gt;Their goals are, in a way, also identical: from a shuffled configuration, reach a goal configuration.&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;How are the Molecube and the Rubik&amp;rsquo;s cube different?&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Their goal configurations are different: the Molecube wants one ball of each color on each face, while the Rubik&amp;rsquo;s cube wants each face to be all the same color.&lt;/li&gt;
&lt;li&gt;There are nine colors on the Molecube, but only six on the Rubik&amp;rsquo;s cube.&lt;/li&gt;
&lt;li&gt;A block on the Rubik&amp;rsquo;s cube has 1–3 colors (one for each face it touches), while a ball on the Molecube is the same color on all &amp;ldquo;sides&amp;rdquo;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The similarities hint at a solution: though the goal configurations are different, the cubes&#39; structures and mechanics are the same. So if I find a goal configuration for the Molecube, I can use the Rubik&amp;rsquo;s cube algorithm to handle all the tricky rearranging involved in actually getting there.&lt;/p&gt;
&lt;p&gt;If that&amp;rsquo;s enough of a framework for you to attempt your own solution, feel free to download the &lt;a href=&#34;https://mhmmoshtaghi.github.io/files/molecube_worksheet.pdf&#34; target=&#34;_blank&#34;&gt;worksheet&lt;/a&gt; I&amp;rsquo;ve created to help you visualize the Molecube as a Sudoku puzzle (with colors instead of numbers). You&amp;rsquo;ll want to stop reading here and come back once you&amp;rsquo;ve completed a goal configuration or if you&amp;rsquo;re stuck and need hints.&lt;/p&gt;
&lt;p&gt;Speaking of hints, the best way to unlock this tricky Sudoku-like color puzzle (getting one color on each face) is to study the Molecube&amp;rsquo;s colors and structure. I asked myself the following questions (which culminated in the table at the top of the &lt;a href=&#34;https://mhmmoshtaghi.github.io/files/molecube_worksheet.pdf&#34; target=&#34;_blank&#34;&gt;worksheet&lt;/a&gt;):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How does the Molecube fit nine colors on a cube with 26 balls?&lt;/li&gt;
&lt;li&gt;How are the colors distributed over the different types of balls (centers, corners, and edges)?&lt;/li&gt;
&lt;li&gt;Are there any patterns that appear when trying to place balls of a certain color so it appears on each face exactly once?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The answers to these questions are revealing. There are three balls of each color, with the important exception of Green, which only has two. Further, Green is the unique color that is on two corners. Red and Purple are each on three edges, and the remaining six colors (White, Black, Orange, Yellow, Light Blue, and Blue) are each on one center, one corner, and one edge. This information — after some careful thinking — reveals the patterns we need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;As in the Rubik&amp;rsquo;s cube, centers opposite one another are always opposite one another (i.e., Black is always opposite White, Orange is always opposite Yellow, and Blue is always opposite Light Blue).&lt;/li&gt;
&lt;li&gt;The only way the two Green corners avoid being on the same face is if they&amp;rsquo;re opposite one another (e.g., upper-right-back and lower-left-front).&lt;/li&gt;
&lt;li&gt;The only way the three Red (or Purple) edges avoid being on the same face is if a Red (or Purple) appears exactly once in each &amp;ldquo;middle band&amp;rdquo; (shown below, left). So each middle band contains exactly one Red and one Purple.&lt;/li&gt;
&lt;li&gt;For any of the remaining colors, (e.g., Blue) there is a center of that color. This blocks the corner of that color from being in the same &amp;ldquo;layer&amp;rdquo;, so the corner must go in the layer opposite the center (shown below, right). Once the position of the corner is fixed, there is only one position the edge of that color can go.&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&#34;rule1.png&#34; style=&#34;display: inline-block; width: 47%; margin-right: 2%&#34;/&gt;
&lt;img src=&#34;rule2.png&#34; style=&#34;display: inline-block; width: 47%; margin-left: 2%&#34;/&gt;
&lt;p&gt;Using these rules and some trial and error, I found the solution shown below, also detailed in the &lt;a href=&#34;https://mhmmoshtaghi.github.io/files/molecube_worksheet_solved.pdf&#34; target=&#34;_blank&#34;&gt;worksheet solution&lt;/a&gt;. (An interesting aside: I don&amp;rsquo;t know if this is the only solution, but any solution works for the reduction). To relate the Molecube solution to the Rubik&amp;rsquo;s cube solution, we simply treat each 3×3 face on the Molecube as a &amp;ldquo;color&amp;rdquo; on the Rubik&amp;rsquo;s cube. (For example, the Black ball at the top-left of the White-center face becomes the Red-White-Green block on the Rubik&amp;rsquo;s cube). This completes the transformation step of the reduction.&lt;/p&gt;
&lt;img src=&#34;sudoku-soln.jpg&#34; style=&#34;display: inline-block; width: 47%; margin-right: 2%&#34;/&gt;
&lt;img src=&#34;rubiks-mapping.jpg&#34; style=&#34;display: inline-block; width: 47%; margin-left: 2%&#34;/&gt;
&lt;h2 id=&#34;rubik-ing-the-molecube&#34;&gt;Rubik-ing the Molecube&lt;/h2&gt;
&lt;p&gt;With the difficult transformation step out of the way, the rest of the reduction is easy. You can solve any shuffled Molecube just like you would a Rubik&amp;rsquo;s cube (assuming you know how to do that), but instead of aiming to have faces with all the same color, you aim to build the goal configuration we got from the transformation (above, left). To make this easier for me to visualize, I made a 3D rendering of my solution (front view on the left, back view on the right).&lt;/p&gt;
&lt;img src=&#34;featured.png&#34; style=&#34;display: inline-block; width: 47%; margin-right: 2%&#34;/&gt;
&lt;img src=&#34;solved-back.png&#34; style=&#34;display: inline-block; width: 47%; margin-left: 2%&#34;/&gt;
&lt;p&gt;I was pleasantly surprised at how much Rubik&amp;rsquo;s cube muscle memory I still had from speedcubing in junior high (though if you need a refresher, I found &lt;a href=&#34;https://hobbylark.com/puzzles/Rubik-Cube-Algorithms&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this tutorial&lt;/a&gt; helpful). Interestingly, some of the steps in the Rubik&amp;rsquo;s cube &amp;ldquo;algorithm&amp;rdquo; are unnecessary for the Molecube. Remember the earlier observation that the Molecube&amp;rsquo;s balls are each a single color while the Rubik&amp;rsquo;s cube blocks can have 1–3 colors each? This means that the Molecube doesn&amp;rsquo;t care if its balls are rotated &amp;ldquo;in place&amp;rdquo;, though this is a problem for the Rubik&amp;rsquo;s cube (see the example below). So any steps in the Rubik&amp;rsquo;s cube algorithm that are meant to fix things like this can be skipped entirely.&lt;/p&gt;














&lt;figure  &gt;
  &lt;div class=&#34;d-flex justify-content-center&#34;&gt;
    &lt;div class=&#34;w-100&#34; &gt;&lt;img src=&#34;https://usercontent2.hubstatic.com/14101285_f1024.jpg&#34; alt=&#34;&#34; loading=&#34;lazy&#34; data-zoomable width=&#34;90%&#34; /&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/figure&gt;
&lt;h2 id=&#34;but-does-it-work&#34;&gt;But Does It Work?&lt;/h2&gt;
&lt;p&gt;To show that the reduction approach not only works but is also reasonably fast, here&amp;rsquo;s me solving the Molecube in just under 2 minutes.&lt;/p&gt;

&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
  &lt;iframe src=&#34;https://www.youtube.com/embed/QRtTLvtXWrQ&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allowfullscreen title=&#34;YouTube Video&#34;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;br/&gt;
&lt;p&gt;There are a &lt;em&gt;lot&lt;/em&gt; of Rubik&amp;rsquo;s cube-inspired puzzles these days (for example, the &lt;a href=&#34;http://www.recenttoys.com/meffert-ghost-cube-twister-puzzle/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Ghost Cube&lt;/a&gt; and the &lt;a href=&#34;http://www.recenttoys.com/meffert-pyraminx-twister-puzzle/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Pyraminx&lt;/a&gt;). But solving the Molecube by reduction makes me wonder just how many of these new puzzles share a similar relationship to the original Rubik&amp;rsquo;s cube. If these relationships exist, we&amp;rsquo;d find that these new puzzles aren&amp;rsquo;t really new at all; they&amp;rsquo;re just an old puzzle we know how to solve, but with new names and nice packaging.&lt;/p&gt;
</description>
    </item>

  </channel>
</rss>
