Jekyll2022-12-02T06:56:34-06:00https://benjamin-hackl.at/Benjamin HacklI am a mathematician currently employed at the University of Klagenfurt. This is my personal web space.New talk at AofA22, and a note on typesetting math with reveal.js2022-06-20T00:00:00-05:002022-06-20T00:00:00-05:00https://benjamin-hackl.at/blog/2022/06/AofA22-revealjs-and-latex<p>I had the pleasure of presenting recent joint work with
<a href="http://info.tuwien.ac.at/panholzer/">Alois Panholzer</a> and
<a href="https://katalog.uu.se/profile/?id=N19-23">Stephan Wagner</a> on the analysis of
a stochastic process involving <a href="https://drops.dagstuhl.de/opus/volltexte/2022/16096">iteratively uncovering</a>
the vertices and edges of labeled trees at <a href="https://www.math.aau.at/AofA2022/">AofA22</a>.</p>
<p>While preparing the slides for my talk (see embed below), I stumbled over
an interesting solution for a problem that has somewhat haunted me while
using <a href="https://revealjs.com">reveal.js</a>, namely the missing ability to
make parts of typeset math into <em>fragments</em> (which means that these
parts can be faded in separately, think <code>\pause</code> in LaTeX-beamer).</p>
<div>
<div style="position:relative;padding-top:56.25%;">
<iframe style="position: absolute; top:0; left:0; width:100%; height:100%;" frameborder="0" src="/downloads/talks/2022-06-20-AofA22/index.html">
<p>Visit the slides <a href="/downloads/talks/2022-06-20-AofA22/">directly here</a> in case
this embed does not load for you.</p>
</iframe>
</div>
</div>
<p>The solution I applied has been provided in <a href="https://github.com/hakimel/reveal.js/issues/1365">this GitHub issue</a>,
with a working (recent) version of the proposal in the files provided in
<a href="https://github.com/hakimel/reveal.js/issues/1365#issuecomment-727893637">this comment</a>
by <a href="https://github.com/manuelbb-upb">@manuelbb-upb</a>. With the updated <code>math.js</code> provided
there, reveal.js’ MathJaX plugin is extended (among other things) with
a <code>\fragment{<fragment-index>}{<fragment-content>}</code> command that can be used
like</p>
<pre><code>\[ x^2 \fragment{1}{ + y^2} \fragment{2}{= z^2} \]
</code></pre>
<p>to produce a typeset equation that will be gradually uncovered to first show $x^2$, then $x^2 + y^2$,
and then the full $x^2 + y^2 = z^2$.</p>
<p>Unfortunately the order does not seem to combine well with nodes with set <code>data-fragment-index</code>
outside of the math environment, but it is still nice to be able to use at least some
<em>fragment-magic</em> in typeset math.</p>I had the pleasure of presenting recent joint work with Alois Panholzer and Stephan Wagner on the analysis of a stochastic process involving iteratively uncovering the vertices and edges of labeled trees at AofA22.From rolling dice to differential equations: a discussion of four generating function problems2022-06-03T05:00:00-05:002022-06-03T05:00:00-05:00https://benjamin-hackl.at/blog/2022/06/generating-functions-3b1b<p>In this <del>video</del> blog post, I want to discuss the
four exercises that 3blue1brown left at the end of his latest video, plus some
additional background and context from the point of view of someone who works
with generating functions a lot.</p>
<p><strong>Note:</strong> This article is, in a sense, the written counterpart to the <em>manimated</em>
video I have produced for <a href="https://youtube.com/benjaminhackl">my YouTube channel</a>. Feel free to check it out and
leave a like in case you enjoyed it or found it helpful! :-)</p>
<div style="margin-bottom: 1em; max-width: 800px;">
<div class="embed-container">
<iframe src="https://www.youtube.com/embed/9SzwfM-S9sk" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
</div>
</div>
<p>At the end of 3blue1brown’s <a href="https://youtu.be/bOXCLR3Wric">recent video on an innocent looking enumeration
problem</a> (which I highly recommend watching),
he left four exercise problems.
I do <em>a lot</em> with generating functions in my mathematical life, so I thought it
would be a fun idea to discuss these four problems from my point of view – and
I’ll also throw in some bonus material on top.</p>
<p>Before we jump into the problems, let me recommend some more literature: aside
from <a href="https://books.google.com/books?id=XOPMBQAAQBAJ">Herbert Wilf’s <em>Generatingfunctionology</em></a>
which Grant recommended in his video, I would also like to add to add
<a href="https://books.google.com/books?id=pntQAAAAMAAJ"><em>Concrete Mathematics</em> by Graham, Knuth, and Patashnik</a>
because I really like both the way how the book is written in general,
as well as their approach of introducing generating functions in particular. And
if you would like to see how the theory around generating functions can be
developed further in a more analytical direction, I also want to recommend my
favourite advanced book on that topic; the “purple bible”: <a href="http://algo.inria.fr/flajolet/Publications/book.pdf"><em>Analytic Combinatorics</em> by
Flajolet and Sedgewick</a>.
If there is interest – let me know in the YouTube comments below my video! –
I’ll talk a bit more about the very powerful, systematic approach to counting
with generating functions described there in a future video.</p>
<p>Now, with that out of the way, let us discuss the four problems.</p>
<hr />
<h2 id="problem-1-the-generating-function-and-the-expected-value">Problem 1: The Generating Function and the Expected Value</h2>
<p><strong>Problem statement:</strong> Take the derivative of both sides of
\[ \frac{1}{1-x} = \sum_{n\geq 0} x^n. \]
How can you use this to compute the expected number of times you
have to roll a fair six-sided die before seeing the number 1?</p>
<p><strong>Solution:</strong>
The instructions from the first part of the problem are a bit
clearer if we take a look at the second part of the problem,
the one about the expected value, first: to determine the expected number
of times we have to roll the die until we roll 1, we need to
think about probabilities: We have a probability of $1/6$ to
roll 1 with our first throw, in which case we had to wait for
0 throws before. Otherwise we rolled a non-1 (which happened
with a probability of $5/6$) and now have to roll the die again.
With a probability of $1/6$ we roll the 1 in our second attempt
(which means we had to wait for 1 throw before), and with
a probability of $5/6$ we – again – fail to get 1.</p>
<p style="text-align: center;">
<img src="/assets/img/2022-06/throw-diagram.webp" alt="State diagram of throws" style="max-width: 750px; height: auto; width: 100%;" />
</p>
<p>With the help of this diagram it is also not too hard to see that
in general, the probability that we have to wait $n$ times
before rolling 1 for the first time is $(5/6)^n \cdot (1/6)$.</p>
<p>To find the expected number of throws we have to wait for from
there, we sum over all possible events (0 rolls before; 1 roll
before; 2 rolls before, …) and multiply the number of times
we had to wait with the corresponding probability. The
sum we want to evaluate therefore is</p>
<p>\[
\begin{aligned}
\mathbb{E} &= 0\cdot \frac{1}{6} + 1\cdot \frac{5}{6} \cdot \frac{1}{6} +
2 \cdot \bigg(\frac{5}{6}\bigg)^2 \frac{1}{6} + \cdots \\
& = \sum_{n\geq 0} n \cdot \bigg(\frac{5}{6}\bigg)^n \cdot \frac{1}{6}\\
& = \frac{1}{6} \sum_{n\geq 0} n \cdot \bigg(\frac{5}{6}\bigg)^n.
\end{aligned}
\]</p>
<p>This is as far as we can get at this point; let us now turn to the
more “mechanical” part of the problem (taking derivatives) and then
we will see how to combine the two parts.</p>
<p>Let me add some bonus content though: the sum on the right is a
so-called <em>geometric series</em>, and from an analytic point of view
it holds for all real (or complex) $x$ with absolute value less
than 1. The identity can be derived directly, let us take a look:
let $S_n = 1 + x + x^2 + \cdots + x^n$ denote the geometric
sum of the terms from $1$ to $x^n$. Simply multiplying both sides
with $x$ yields
\[
x S_n = x + x^2 + x^3 + \cdots + x^{n+1},
\]
a sum which shares almost all of its summands with the <em>original</em>
$S_n$. And so, if we subtract $x S_n$ from $S_n$, we find
\[
\begin{aligned}
S_n - x S_n &= (1 + x + x^2 + \cdots + x^n) - (x + x^2 + \cdots + x^{n+1}) \\
&= 1 - x^{n + 1}
\end{aligned}
\]
If we factor out $S_n$ on the left-hand side, we are left with
$S_n (1 - x) = 1 - x^{n+1}$, or, as long as $x\neq 1$,
\[
S_n = \frac{1 - x^{n+1}}{1 - x}.
\]
If we consider what happens when $n$ grows large (<em>tends to infinity</em>),
then as long as $|x| < 1$, the term $x^{n+1}$ will tend to $0$.
Everything else on the right-hand side does not depend on $n$,
and such we have proved the identity for the geometric series,
\[
1 + x + x^2 + x^3 + \cdots = \frac{1}{1 - x}.
\]
A technical thing to note: given that we are differentiating an
identity; in particular, something that holds in an entire neighborhood
of $x = 0$ and not just for one particular value of $x$, we are allowed
to take the derivative on both sides and we will obtain a valid
equation again.</p>
<p>Differentiating the left-hand side gives
(using the chain rule and the power rule):
\[ \frac{\partial\,}{\partial x} \frac{1}{1 - x}
= \frac{\partial\,}{\partial x} (1 - x)^{-1}
= (-1)\cdot (1 - x)^{-2} \cdot (-1) = \frac{1}{(1 - x)^2},
\]
and differentiating the right-hand side yields (by moving the
derivative inside of the sum and then applying the power rule)
\[ \frac{\partial\,}{\partial x} \sum_{n\geq 0} x^n
= \sum_{n\geq 0} \frac{\partial\,}{\partial x} x^n
= \sum_{n\geq 0} n x^{n-1}.
\]
Combining the two sides then gives us the useful identity
\[ \frac{1}{(1 - x)^2} = \sum_{n\geq 0} n x^{n - 1}, \]
which looks (unsurprisingly) familiar: if we multiply both sides with $x$
we arrive at
\[ \frac{x}{(1 - x)^2} = \sum_{n\geq 0} n x^n, \]
which helps us to evaluate the sum for the expected value $\mathbb{E}$
that we derived above: setting $x = 5/6$
gives, when reading from right to left,
\[ \sum_{n\geq 0} n \cdot \bigg(\frac{5}{6}\bigg)^n = \frac{5/6}{(1 - 5/6)^2} = 30, \]
and therefore we find that there are
\[ \mathbb{E} = \frac{1}{6} \cdot 30 = 5 \]
expected throws before we roll a 1 with a fair die.</p>
<p>Final note before we move on: the probability distribution
that the number of throws before we hit 1 follows is the
so-called <em>geometric distribution</em> (named like that because
its probabilities form a <em>geometric sequence</em>).</p>
<hr />
<h2 id="problem-2-a-binomial-sum">Problem 2: A binomial sum</h2>
<p><strong>Problem statement:</strong> Compute the sum
\[ \sum_{k=0}^n \binom{n}{k} 2^k. \]</p>
<p><strong>Solution:</strong> This is a problem that I personally like a lot, and I will
share some bonus material about it after discussing the solution.
To solve this with the <em>generating function approach</em>, we make
use of the binomial theorem, which states that for any non-negative
integer $n$ and numbers $a$ and $b$ we have
\[ (a + b)^n = \sum_{k=0}^{n} \binom{n}{k} a^k b^{n - k}. \]
Observe that if we set $a = x$, and $b = 1$, that we find
\[ (x + 1)^n = \sum_{k=0}^{n} \binom{n}{k} x^k. \]
The right-hand side here already resembles the sum from
the problem statement a lot, all that remains to do is
to set $x = 2$ and the equation reads, from right to left,
\[ \sum_{k=0}^{n} \binom{n}{k} 2^k = (2 + 1)^n = 3^n. \]</p>
<h5 id="bonus-material-an-alternative-explanation">Bonus material: an alternative explanation</h5>
<p>Identities like these are usually also an invitation to think about
a more direct, combinatorial explanation. And it is not too hard
to find one here: both sides of the equation
\[ \sum_{k=0}^n \binom{n}{k} 2^k = 3^n \]
express the number of possible colourings of the numbers from $1$
to $n$ with three colors (say red, green, blue):</p>
<ul>
<li>To arrive at the right-hand side, we go through all of the
numbers one by one and pick one of the three possible colors
for each of them. There are $n$ numbers with $3$ choices each,
and therefore there are $3^n$ possible choices.</li>
<li>And to obtain the left-hand side we first decide that $k$ of
the numbers should either be red <em>or</em> green, then we choose
these $k$ numbers in one of the $\binom{n}{k}$ possible ways,
and decide for each of them whether it is red or green ($2$ choices
for each of the $k$ numbers, thus $2^k$ possible choices). The
remaining $n-k$ numbers that were not chosen are colored blue.
For some specific $k$ we thus find $\binom{n}{k} 2^k$
possible colourings, and in order to obtain all possible colourings
we have to sum over all possible values of $k$, from $k=0$ to $k=n$.</li>
</ul>
<p>The fact that these two strategies with their corresponding counts
both yield all possible colourings of the numbers from $1$ to $n$
with three colors proves that the identity holds. (In combinatorics,
this sort of argument is usually referred to as <em>double counting</em>.)</p>
<hr />
<h2 id="problem-3-fibonacci-numbers-and-a-differential-equation">Problem 3: Fibonacci numbers and a differential equation</h2>
<p><strong>Problem statement:</strong> Let $f_n$ be the $n$-th Fibonacci number
and consider the generating function
\[ F(x) = \sum_{n\geq 0} f_n \frac{x^n}{n!}. \]
Explain why the differential equation $F^{\prime\prime}(x) = F’(x) + F(x)$
is true. For bonus points, solve this equation and use it to
find a closed-form expression for $f_n$.</p>
<p><strong>Solution:</strong> To find an explanation for the differential equation,
we first investigate what happens if we differentiate a generating
function of this particular shape; this is completely independent
of $f_n$ being a Fibonacci number.</p>
<p>A generating function with the particular shape of $F(x)$, i.e., with
the $n$-th coefficient being normalized by $n!$, is called exponential
generating function. This is because the exponential function, as you
might know, has the series expansion
\[ e^x = 1 + x + \frac{x^2}{2} + \frac{x^3}{6} + \cdots = \sum_{n\geq 0} 1\cdot \frac{x^n}{n!}, \]
that is, $e^x$ is the exponential generating function of the constant
1-sequence.</p>
<p>For the derivative of $F(x)$, we find
\[
\begin{aligned}
F’(x) &= \frac{\partial\,}{\partial x} \sum_{n\geq 0} f_n \frac{x^n}{n!} \\
&= \sum_{n\geq 0} \frac{\partial\,}{\partial x} f_n \frac{x^n}{n!} \\
&= \sum_{n\geq 0} f_n \frac{n x^{n-1}}{n!} \\
&= \sum_{n\geq 1} f_n \frac{x^{n-1}}{(n-1)!} \\
&= \sum_{n\geq 0} f_{n+1} \frac{x^n}{n!}.
\end{aligned}
\]
In other words, if $F(x)$ is the exponential generating function of
the sequence $f_0, f_1, f_2, \dots$, then $F’(x)$ is the exponential
generating function of the shifted sequence $f_1, f_2, f_3, \dots$ – and
we can simply apply the same argument again to see that the second
derivative then is the exponential generating function of
$f_2, f_3, f_4, \dots$. This is one of the most useful properties
of exponential generating functions.</p>
<p>Now, back to our concrete situation where $f_n$ is the $n$-th
Fibonacci number. By using the corresponding <em>Fibonacci recurrence</em>,
$f_{n+2} = f_{n+1} + f_{n}$, we obtain
\[
\begin{aligned}
F^{\prime\prime}(x) &= \sum_{n\geq 0} f_{n+2} \frac{x^n}{n!} = \sum_{n\geq 0} (f_{n+1} + f_{n}) \frac{x^n}{n!}\\
&= \sum_{n\geq 0} f_{n+1} \frac{x^n}{n!} + \sum_{n\geq 0} f_n \frac{x^n}{n!}\\
&= F’(x) + F(x),
\end{aligned}
\]
the differential equation we were asked to explain!</p>
<p>In general, this is a problem for which generating functions are
very useful for, recurrences for sequences can often be translated
into functional equations of their corresponding generating functions;
and with a bit of luck, these equations can be solved to then give
explicit formulas for the elements in the sequence. A very neat trick!</p>
<p>We also want to get full points from Grant, so let us solve the
differential equation: without going into too much detail why
this works, we use the Ansatz $F(x) = e^{\lambda x}$ (which means that we
assume that the solution has a certain shape – you could say that we are
just making an educated guess and then see how far we can take it),
where $\lambda$ is a constant. Plugging it into the
differential equation and bringing everything to one side gives
\[ \lambda^2 e^{\lambda x} - \lambda e^{\lambda x} - e^{\lambda x} = 0. \]
Now, because $e^{\lambda x}$ is never zero we may conclude that
if our Ansatz should work, the equation
\[ \lambda^2 - \lambda - 1 = 0 \]
has to hold – and indeed, we find that
\[
\lambda_+ = \frac{1 + \sqrt{5}}{2}, \quad \lambda_- = \frac{1 - \sqrt{5}}{2}
\]
are solutions to the quadratic equation (and at this point we, obligatorily,
have to point out that $\lambda_+$ is “coincidentally” $\varphi$, the golden ratio).</p>
<p>You can convince yourself that we actually just found <em>some</em> solutions to the
differential equation, both $x\mapsto e^{\lambda_+ x}$ as well as $x\mapsto e^{\lambda_- x}$
satisfy $F^{\prime\prime}(x) = F’(x) + F(x)$ – and so does a <em>linear combination</em>
of the two, $x\mapsto c_+ e^{\lambda_+ x} + c_- e^{\lambda_- x}$ for constants $c_-$ and $c_+$;
plug the functions into the differential equation and you will see that it all works out.</p>
<p>However, we are not looking for <em>any</em> solution to the differential equation, we are looking
for a fairly specific one: the solution should be the generating function for Fibonacci
numbers, after all! To nail down the particular solution we are looking for, we have
to use some information of the generating function – for example, that we want to
have $F(0) = f_0 = 0$, the $0$-th Fibonacci number, and the derivative as the
generating function of the shifted sequence should satisfy $F’(0) = f_1 = 1$.</p>
<p>Plugging these conditions into the <em>general</em> solution,
\[ F(x) = c_+ e^{\lambda_+ x} + c_- e^{\lambda_- x} \]
translates to the equations $c_+ + c_- = 0$, and
$c_+ \lambda_+ + c_- \lambda_- = 1$. Plugging $c_- = - c_+$
(from the first equation) into the second one yields
\[ 1 = c_+ \lambda_+ - c_+ \lambda_- = c_+ (\lambda_+ - \lambda_-), \]
and a straightforward computation gives $\lambda_+ - \lambda_- = \sqrt{5}$
so that we arrive at $c_+ = 1/\sqrt{5}$ and $c_- = -1\sqrt{5}$.</p>
<p>Overall, this implies
\[ F(x) = \frac{1}{\sqrt{5}} e^{\lambda_+ x} - \frac{1}{\sqrt{5}} e^{\lambda_- x}, \]
and the explicit formula for $f_n$ can now be obtained by rewriting
the exponential functions into their series representation,
\[
\begin{aligned}
F(x) &= \frac{1}{\sqrt{5}} \sum_{n\geq 0} \lambda_+^n \frac{x^n}{n!} - \frac{1}{\sqrt{5}} \sum_{n\geq 0} \lambda_-^n \frac{x^n}{n!} \\
&= \sum_{n\geq 0} \frac{1}{\sqrt{5}} (\lambda_+^n - \lambda_-^n) \frac{x^n}{n!}.
\end{aligned}
\]
This proves Binet’s explicit formula for the $n$-th Fibonacci number:
\[
f_n = \frac{1}{\sqrt{5}} \bigg(\bigg(\frac{1 + \sqrt{5}}{2}\bigg)^n -
\bigg(\frac{1 - \sqrt{5}}{2}\bigg)^n\bigg).
\]</p>
<hr />
<h2 id="problem-4-a-useful-product">Problem 4: A useful product</h2>
<p><strong>Problem statement:</strong> Suppose $f(x) = \sum_{n\geq 0} a_n x^n$.
What do the coefficients of
\[ \frac{f(x)}{1 - x} \]
tell you?</p>
<p><strong>Solution:</strong> This final problem is a bit shorter again, but invites
us to prove a very useful sequence construction with many applications:
for example, one can use this in the average case analysis of Quicksort
(and if that has made you curious, let me know; I might discuss this
in a future video … :-) ).</p>
<p>Here is how we can tackle this:
\[
\begin{aligned}
\frac{f(x)}{1 - x} &= \frac{1}{1-x} \sum_{\ell\geq 0} a_{\ell} x^{\ell}
= \sum_{\ell\geq 0} a_{\ell} \frac{x^{\ell}}{1 - x}\\
&= \sum_{\ell\geq 0} a_{\ell} x^{\ell} (1 + x + x^2 + \cdots) \\
&= \sum_{\ell\geq 0} a_{\ell} (x^{\ell} + x^{\ell+1} + x^{\ell+2} + \cdots) \\
&= \sum_{\ell\geq 0} a_{\ell} \sum_{n\geq \ell} x^{n}.
\end{aligned}
\]
The trick to make this expression nicer is to change the order of
summation. The following image should help to visualize the situation:</p>
<p style="text-align: center;">
<img src="/assets/img/2022-06/order-summation.webp" alt="Visualization of order of summation" style="max-width: 450px; height: auto; width: 100%;" />
</p>
<p>In the grid, every cell corresponds to one summand. In the original sum,
we first iterate over the columns ($\ell\geq 0$), and then sum over all cells once we have
passed a certain threshold ($n \geq \ell$). If we change the order of summation,
we first iterate over the rows ($n \geq 0$), and then over all cells <strong>up to</strong>
a certain column threshold ($0\leq \ell\leq n$).</p>
<p>Practically, this means that we rewrite
\[
\sum_{\ell\geq 0} a_{\ell} \sum_{n\geq \ell} x^{n} =
\sum_{n\geq 0} \bigg(\sum_{\ell = 0}^{n} a_{\ell} \bigg) x^{n},
\]
or alternatively, in the expanded form,
\[
a_0 (1 + x + x^2 + x^3 + \cdots) + a_1 (x + x^2 + x^3 + \cdots) + a_2 (x^2 + x^3 + \cdots) +
a_3 (x^3 + \cdots) + \cdots
\]
becomes
\[
a_0 + (a_0 + a_1)x + (a_0 + a_1 + a_2)x^2 + (a_0 + a_1 + a_2 + a_3)x^3 + \cdots.
\]
This representation allows us to read off the coefficients
of $f(x)/(1-x)$: if $f(x)$ is the generating function with coefficient
sequence $a_0, a_1, a_2, \dots$, then $f(x)/(1-x)$ has coefficient sequence
\[
a_0, a_0 + a_1, a_0 + a_1 + a_2, a_0 + a_1 + a_2 + a_3, \dots,
\]
that is, partial sums of the original sequence.</p>
<hr />
<p>And this concludes the discussion of the solutions of the
four problems. Let me know <a href="https://youtu.be/9SzwfM-S9sk">in the YouTube comments</a>:
did you find this helpful? Are you curious about more generating
function “magic”?</p>
<p>Thank you very much for <del>watching</del> reading, and see you in the
next <del>video</del> blog post!</p>In this video blog post, I want to discuss the four exercises that 3blue1brown left at the end of his latest video, plus some additional background and context from the point of view of someone who works with generating functions a lot.Manim on a Raspberry Pi2022-05-10T05:00:00-05:002022-05-10T05:00:00-05:00https://benjamin-hackl.at/blog/2022/05/manim-raspberry<p>Due to one of the libraries that Manim depends on (<a href="https://pypi.org/project/skia-pathops/"><code>skia-pathops</code></a>)
not specifically supporting the architecture of Raspberry Pi, trying to install <code>manim</code> might
lead to an error that reads along the lines of this:</p>
<pre><code>Traceback (most recent call last):
File "bin/fetch-gn", line 26, in <module>
cpu = {'amd64': 'amd64', 'arm64': 'arm64', 'x86_64': 'amd64'}[platform.machine().lower()]
KeyError: 'armv7l'
<...>
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-_vcb3idb/skia-pathops/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-ziy4l3qx/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-_vcb3idb/skia-pathops/
</code></pre>
<p>This is a problem outside of Manim, and can only be fully resolved when (if?) the maintainers
of <code>skia-pathops</code> explicitly add support for other architectures. While this is unsatisfactory,
there is little we (from the Manim community) can do about it directly. There is, however,
a compromise: it is possible to install a version of the library which
marks <code>skia-pathops</code> as an optional dependency. Assuming that the <code>pip</code> executable
is linked to the appropriate Python 3.7+ installation (you might need to call, e.g., <code>pip3</code> instead)
you can install the patched version by running</p>
<pre><code>pip install git+https://github.com/behackl/manim@optional-pathops
</code></pre>
<p>instead of the usual <code>pip install manim</code>. With this version, if <code>skia-pathops</code> is unavailable,
the classes in <a href="https://docs.manim.community/en/stable/reference/manim.mobject.geometry.boolean_ops.html">Manim’s <code>boolean_ops</code> module</a>
will not be available (which you should also be notified of via a logged warning whenever
you <code>import manim</code>).</p>
<p>In case the installation of the patched version fails with a mention of a non-existing <code>setup.py</code>
file, make sure to use a reasonably recent version of Python (3.7 and up), and make sure you
are using an up-to-date version of <code>pip</code> by running <code>pip install -U pip</code>.</p>
<p>Please note: this patched version was fabricated based on some commit on the development branch after
the release of <code>v0.15.2</code> (in May 2022). If you need a different version, take a look at the changes
I have made to <code>pyproject.toml</code> and <code>manim/__init__.py</code> in
<a href="https://github.com/behackl/manim/commit/859deb56ff7d2e82ae08bf699c372d50e7a74e4d">this commit</a>
and apply them to whichever version you require. The lockfile can be regenerated via <code>poetry lock</code>.</p>
<p>If you feel particularly adventurous and would like to try to build Skia and the corresponding
Python bindings fully yourself, check out <a href="https://gist.github.com/naveen521kk/8cce2ba129312cf38f4451d6d10d61ad">these (theoretical) instructions</a>;
try at your own risk!</p>
<p>In case anything about the incompatibility of <code>skia-pathops</code> changes, I’ll try to update this post accordingly.</p>Due to one of the libraries that Manim depends on (skia-pathops) not specifically supporting the architecture of Raspberry Pi, trying to install manim might lead to an error that reads along the lines of this:A Report from Uppsala2021-06-10T05:00:00-05:002021-06-10T05:00:00-05:00https://benjamin-hackl.at/blog/2021/06/report-from-uppsala<p>It’s time for an update! A <strong>lot</strong> of stuff has happened in the past
few weeks, and I think my blog is a good space to keep track of
it all (at least a bit 😅).</p>
<h3 id="--">🇦🇹 → 🇸🇪</h3>
<p>You would think that relocating during a global pandemic would be a
rather complex endeavour – and well, you are right with that assumption.
Nevertheless, I’ve been planning to join <a href="https://www.math.uu.se">Uppsala University</a>
for a postdoc position for a while now, and I’m very happy that things
finally worked out.</p>
<blockquote class="twitter-tweet">
<p lang="en" dir="ltr">It probably doesn't get much more official than that: I'm excited and very happy to have joined the Mathematics dept. at <a href="https://twitter.com/UU_University?ref_src=twsrc%5Etfw">@UU_University</a>. :-) <a href="https://t.co/xZjH5vfgUG">pic.twitter.com/xZjH5vfgUG</a></p>
<p>— Benjamin Hackl (@behackl) <a href="https://twitter.com/behackl/status/1391679614167171074?ref_src=twsrc%5Etfw">May 10, 2021</a></p>
</blockquote>
<p>The apartment that I’m renting together with my girlfriend is actually
really nice (and by now also well-equipped with a more than suitable
home office); I’m pretty sure that we’ve had a fair amount of luck with
getting it, especially considering that formal procedures can be a bit
complicated for people without a Swedish social security number. (Basically,
without a <em>Personnummer</em>, you’re not a person. I can’t even get through in
<a href="https://twitter.com/behackl/status/1390590021921656834">the hotline of my internet provider</a>,
but well, that’s life. I hope to be a real person soon again.)</p>
<p>From a mathematical point of view, I’m really looking forward to
an exciting time in Uppsala.</p>
<h3 id="maintaining-manim">Maintaining Manim</h3>
<p>A bit less than a year ago, when <a href="/blog/2020/08/summerinterns-2020.html">I’ve supervised summer interns</a>
together with my colleague <a href="https://www.math.aau.at/rissner/">Rosi Rissner</a>, I got
interested in <a href="http://3blue1brown.com">Grant “3b1b” Sanderson’s</a> Python
animation library <a href="https://www.manim.community">Manim</a>. I’ve always been interested
in science communication, and Manim seemed like the right tool (videos!) at the right
time (during a pandemic!) to pick up.</p>
<p><img src="https://raw.githubusercontent.com/ManimCommunity/manim/main/logo/cropped.png" alt="The ManimCommunity logo" /></p>
<p>In May 2020, a <a href="https://github.com/ManimCommunity/manim">small community</a> has decided
to start maintaining the library that Grant generously made public. And well,
a series of escalations (mainly caused by the fact that I like working on Open Source
software <strong>way</strong> too much) have resulted in me becoming one of the maintainers / organization
administrators for <em>ManimCommunity</em>.</p>
<p>We have recently <a href="https://github.com/ManimCommunity/manim/releases/tag/v0.7.0">published a new release</a>,
version <code>v0.7.0</code>, with an <a href="https://docs.manim.community/en/latest/changelog/0.7.0-changelog.html">impressive changelog</a>
(especially considering that according to our release cycle we release once a month).</p>
<blockquote class="twitter-tweet">
<p lang="en" dir="ltr">Manim Community v0.7.0 has been released! 🎉 This month's release includes new Mobjects and improvements to our documentation. See more at <a href="https://t.co/budgf0Zfbp">https://t.co/budgf0Zfbp</a> <a href="https://t.co/HkmBo7h3xE">pic.twitter.com/HkmBo7h3xE</a></p>
<p>— Manim Community (@manim_community) <a href="https://twitter.com/manim_community/status/1400945857122340867?ref_src=twsrc%5Etfw">June 4, 2021</a></p>
</blockquote>
<p>If you have never seen Manim in action, I’d definitely like to point you towards
our <a href="https://docs.manim.community/en/stable/examples.html">example gallery</a> – or
just watch a few of <a href="https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw">Grant’s YouTube videos</a>!
I think that Manim has a lot of potential
for Mathematics and Science education in general. I’m curious to see where the community’s journey
will lead, and I’m honored to, metaphorically, have my hands on the steering wheel.</p>
<h3 id="orchestrating-outreach">Orchestrating Outreach</h3>
<p>In celebration of the 1-year anniversary of the foundation of <em>ManimCommunity</em>,
the community had the idea of organizing a weekend-long <em>hackathon</em> in which
participants could submit short animations fitting to a general theme, including
the opportunity to win prizes. The community aspect of <em>ManimCommunity</em> is pretty
important to me, which is why I’ve been heavily involved in the organization of
the event – <a href="https://www.reddit.com/r/manim/comments/nk5sk3/announcement_1st_manim_hackathon_june_5_june_6/">which took place during the last weekend</a>.</p>
<p>The video presentation of the opening ceremony can be found <a href="https://www.twitch.tv/videos/1051297838">here on Twitch</a>
(of course I’ve streamed it! 😄), and given that the presentation has some interesting
numbers I’ll also embed it here.</p>
<div class="embed-container">
<iframe frameborder="0" src="https://benjamin-hackl.at/downloads/talks/2021-06-04-manimhackathon/"></iframe>
</div>
<p>Given that we have done something like this for the first time, we were pretty overwhelmed
by the <strong>more than 100 submissions from about 30 participants</strong> we received during the
weekend. I’m pretty sure that we’ll organize more events like that in the future.</p>
<h3 id="successfully-out-of-school">Successfully out of School…</h3>
<p>Speaking of Twitch, I’ve recently also been live there for a different reason:
it’s the season of the Austrian school leaving exams (<em>Matura</em>), and I once again
streamed myself going through the Mathematics exams. The corresponding
videos for two different school types (which have differing
centralized exams) can be found <a href="https://www.youtube.com/watch?v=W9B-ovZZdX8">here for the AHS</a>,
and <a href="https://youtu.be/Fy3vG8llrNA">here for the BHS (HTL 2)</a>. I enjoy
streaming in that setting, and will likely continue to do so in the future
as well. (I’m actually surprised how many people find these videos by now
organically by searching for <em>Matura</em> on YouTube.)</p>
<div style="margin-bottom: 1em; max-width: 800px;">
<div class="embed-container">
<iframe src="https://www.youtube.com/embed/W9B-ovZZdX8" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
</div>
</div>
<h3 id="-and-into-a-mathematical-summer">… and into a Mathematical Summer</h3>
<p>Yet another pretty big thing that happened recently: after being cancelled last year, the
<a href="https://www.ams.org/programs/research-communities/2021MRC-CompGeom">Mathematics Research Community <em>Combinatorial Applications of Computational Geometry and Algebraic Topology</em></a>
finally took place, and it was indeed a great (virtual) workshop that helped me to
meet new people in/adjacent to my field as well as to pick up some new mathematical problems to work on.</p>
<p><img src="https://www.sagemath.org/pix/logo_sagemath+icon_oldstyle.png" alt="SageMath" /></p>
<p>During the week, I’ve been mainly working together with
<a href="https://www.oeaw.ac.at/ricam/staff/elaine-wong">Elaine Wong</a> and
<a href="https://www.math.umass.edu/directory/graduate-students/jesse-selover">Jesse Selover</a>
to translate some Maple code for finding minimal critical points of multivariate
combinatorial generating functions (it already sounds fancy!) from a
<a href="https://arxiv.org/abs/1905.04187">recent publication by Steve Melczer and Bruno Salvy</a>
to SageMath. Eventually, as soon as everything is polished enough, this should
extend the currently existing module for computations with multivariate
generating functions (see <a href="https://trac.sagemath.org/ticket/31908">trac ticket #31908</a>).</p>
<p>And while we’re talking about SageMath: I’m very happy to report that this year,
I’m mentoring the <a href="https://summerofcode.withgoogle.com/projects/#6096683240259584">project on including support for explicitly bounded error terms (B-Terms)</a>
in this year’s edition of the <a href="https://summerofcode.withgoogle.com">Google Summer of Code</a>.
Thomas has already been quite busy, and a basic prototype for an implementation
of this feature in simple cases is already in reach (trac
tickets <a href="https://trac.sagemath.org/ticket/31922">#31922</a> and
<a href="https://trac.sagemath.org/ticket/31933">#31933</a>).</p>
<p>As usual, the start of the summer is also conference season – in particular,
the <a href="https://www.math.aau.at/AofA2021/">32nd International Conference on Probabilistic, Combinatorial and Asymptotic Methods for the Analysis of Algorithms (AofA2021)</a>
will take place from June 14 to June 17. Due to the circumstances, the
University of Klagenfurt was given the opportunity to host the event
both in 2020 (which was converted to an <em>asynchronous</em> online conference)
and in 2021 (which was converted to a <em>synchronous</em> online conference),
but unfortunately in-presence conferences are still not a particularly
great idea at the moment. I would have said that at least the organizers will
have the opportunity to enjoy the Wörthersee during the week – but in my
case that’s also not quite true. I’m not too sad about it though: I’ve
been told that midsummer in Sweden isn’t too bad either. 😄</p>
<script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>It’s time for an update! A lot of stuff has happened in the past few weeks, and I think my blog is a good space to keep track of it all (at least a bit 😅).Goodbye, Summer interns of 2020!2020-08-07T03:42:00-05:002020-08-07T03:42:00-05:00https://benjamin-hackl.at/blog/2020/08/summerinterns-2020<p>
For the past four weeks, my colleague <a href="https://www.math.aau.at/rissner/">Roswitha Rissner</a>
and I supervised five young mathematicians who joined our department as summer interns.
</p>
<div class='jekyll-twitter-plugin'><blockquote class="twitter-tweet"><p lang="de" dir="ltr">Zweimal Blinzeln, und schon wieder ist ein Monat um: Heute ist der letzte Arbeitstag unserer Praktikant*innen an der <a href="https://twitter.com/alpenadriauni?ref_src=twsrc%5Etfw">@alpenadriauni</a> -- und sie haben wirklich großartige Arbeit geleistet! Die von ihnen produzierten Erklärvideos sind jetzt online: <a href="https://t.co/llMSYbb420">https://t.co/llMSYbb420</a> 🥳🥳🥳 <a href="https://t.co/JswolncZ94">pic.twitter.com/JswolncZ94</a></p>— Benjamin Hackl (@behackl) <a href="https://twitter.com/behackl/status/1291374065001943042?ref_src=twsrc%5Etfw">August 6, 2020</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
<p>
Their task was to create short animated explanation videos for some elementary
mathematical concepts they were interested in and for which we provided theoretical
input. The videos produced by them turned out simply amazing and
<a href="https://www.youtube.com/playlist?list=PLP96UIESN83-AjDAPqk7qNdB0vauJ9sdF">are now available on YouTube</a>!
</p>
<p>
All of these animations were created using <a href="https://github.com/ManimCommunity/manim/">Manim</a>,
with the exception of the animation of the background in the outro, which was created using
<a href="https://www.blender.org/">Blender</a>. Furthermore, they used the royalty free music available
from <a href="https://www.bensound.com/">Bensound</a>.
</p>
<p>
Working with them was a very pleasant and invigorating experience. I hope they enjoy the
remainder of their summer as much as they enjoyed their internship (or, ideally, even a bit
more). ;-)
</p>For the past four weeks, my colleague Roswitha Rissner and I supervised five young mathematicians who joined our department as summer interns.Mathematician tackles Austrian school leaving exam: BHS edition2020-06-07T03:42:00-05:002020-06-07T03:42:00-05:00https://benjamin-hackl.at/blog/2020/06/bhs-matura-2020<p>After a lot of positive feedback for
<a href="/blog/2020/05/matura-2020-stream.html">my video regarding the school leaving exam</a>,
I decided to do the same thing for the school leaving exam in mathematics
for a different Austrian school type (BHS).</p>
<p>And again, it was fun to stream on <a href="https://twitch.tv/behackl">my Twitch channel</a>,
the resulting video can be found below.</p>
<div class="embed-container">
<iframe src="https://www.youtube.com/embed/3o1VN16PU4M" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
</div>After a lot of positive feedback for my video regarding the school leaving exam, I decided to do the same thing for the school leaving exam in mathematics for a different Austrian school type (BHS).Mathematician tackles Austrian school leaving exam2020-05-31T16:10:00-05:002020-05-31T16:10:00-05:00https://benjamin-hackl.at/blog/2020/05/matura-2020-stream<p>As there was some controversy regarding the difficulty of the Austrian school
leaving exam in mathematics, I got interested and wanted to check things out
for myself.</p>
<p>I streamed the whole thing on <a href="https://twitch.tv/behackl">my Twitch channel</a>,
and I’ve uploaded the whole thing (sorry, its in German!)
<a href="https://youtu.be/CznXCkfcZrg">to YouTube</a>. It was the first time that I
streamed some mathematics, but I found it to be really fun and enjoyable.
At this point, I can really see myself doing something like this again in
the future!</p>
<div class="embed-container">
<iframe src="https://www.youtube.com/embed/CznXCkfcZrg" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
</div>
<p><em>Update (04.06.2020):</em> The Austrian newspaper DerStandard has included my video in
<a href="https://www.derstandard.at/story/2000117865325/matura-2020-die-latte-in-mathe-lag-heuer-hoeher">this article</a>
discussing the difficulty of the school leaving exam. This really exceeds any
expectations I had for my stream (<em>none</em>). :-)</p>As there was some controversy regarding the difficulty of the Austrian school leaving exam in mathematics, I got interested and wanted to check things out for myself.Technology for Online Teaching during Social Distancing2020-04-29T00:42:00-05:002020-04-29T00:42:00-05:00https://benjamin-hackl.at/blog/2020/04/technology-covid19<blockquote>
<p>For some reason, my students this semester are happy with what I
have done to move my classes to online formats (which, of course,
was neccessary due to COVID-19). A friend asked me to write an
article containing my views and recommendations for online teaching
for a magazine, resulting in the text below. The article did not
appear yet – but as soon as it does, I’ll update this blog entry
with a link to it.</p>
</blockquote>
<p>The current situation brought about by COVID-19 and social distancing
measures, which have been implemented to fight its rapid spread, have
put various education systems in countries all around the world to the
test. Physical events – including in-person teaching sessions – are
canceled almost everywhere. As a result, lecturers and teachers have
been tasked to “move their classes online”. In Austria, for example,
these measures were implemented at a very early stage and physical
classes were canceled almost overnight.</p>
<p>The <a href="https://www.aau.at">University of Klagenfurt</a> where I work has
found ways to adapt to these new circumstances – and along the way we
have learned several important lessons. I want to share some of them,
and cast light on solutions that have worked well so far.</p>
<p>First and foremost, the most important action during these
extraordinary times is to keep in regular contact with your students
by any means necessary. None of them should have the feeling that they
are being left behind. The question of how to achieve that is not so
easy to answer. Unfortunately, it strongly depends on available
infrastructure. In terms of infrastructure, I first and foremost
recommend using institution approved software, and the software
suggestions that follow can be used where institutional software falls
short.</p>
<p>Something that works very well for our mathematics department is a
dedicated <a href="https://discordapp.com/why-discord#study-groups">Discord</a>
server for our students, which provides a very low-barrier way of
contacting us. This server works better than platforms that lean more
in the direction of forums (e.g., Moodle), or plain email - for many
students, asking a short question in a chat feels a lot easier than
typing up a reply to a forum post or email. Furthermore, discussions
in chats usually move faster than in forums, which is especially an
advantage if someone wants to get clarification on an exercise or
something along those lines – and these are the type of questions we
get most often. Moodle and similar e-learning platforms are
indispensable when it comes to the distribution of teaching material,
and so if your university uses such a platform it is recommended that
you continue to use it.</p>
<p>If you and your students have access to the Microsoft Office suite,
then Microsoft Teams might work well for you. For settings that
involve video calls, I can recommend
<a href="https://jitsi.org/jitsi-meet/">Jitsi</a>, <a href="https://zoom.us/">Zoom</a>
(avoid Zoom though, if possible; there are several <a href="https://www.theverge.com/2020/4/1/21202584/zoom-security-privacy-issues-video-conferencing-software-coronavirus-demand-response">major data
protection concerns</a>) or – in case you administer a server yourself or
want to recommend something to your local administrator –
<a href="https://bigbluebutton.org/">BigBlueButton</a>. The latter option, BigBlueButton, is the solution that
the University of Klagenfurt has made use of to create official
classrooms, and it works very well for streaming my lectures via
screen sharing. The aforementioned service, Discord, has a similar
feature that allows sharing your screen to a group of up to 50 people,
but for data protection reasons I prefer to stick to a local solution
when it comes to streaming lectures. I do enjoy the Discord streaming feature
for answering student questions outside of lectures, though!</p>
<p>Such a teaching setting where you are able to share your screen or a
webcam image to your students allows you not only to share prepared
presentations, but also to share your handwriting with them. For this,
I can recommend the open source software
<a href="http://xournal.sourceforge.net/">Xournal</a> (or
<a href="https://github.com/xournalpp/xournalpp">Xournalpp</a> – which is
Xournal rewritten in C++) or <a href="https://www.microsoft.com/de-at/microsoft-365/onenote/digital-note-taking-app">Microsoft
OneNote</a>,
should you have access to it. Especially when it comes to lectures in
mathematics, I believe that students profit more from developing
theory together in a blackboard-type lecture than from having theory
thrown at them from slides – which is why I highly recommend streaming
your (digital) handwriting with a combination of one of the
communication tools above together with Xournal / OneNote or a similar
piece of software – if your infrastructure allows it, of course.</p>
<p>The platforms mentioned above are helpful for communication with
students from all disciplines, including formal sciences. Many
questions that I discuss with my students are on a level where reading
and discussing some pseudo-formatted formulas are sufficient. For more
involved questions, it is always possible to exchange pictures of
hand-written notes; something that is possible within all
communication platforms mentioned above.</p>
<p>Aside from these software suggestions, I have some further
recommendations when it comes to distance teaching, apart from staying
in contact. It might be a very rational first reflex to hand out a
large collection of teaching material to your students so they can
study it at their own pace – but try not to do that. The idea that
students should learn at their own pace is a good one, but handing out
too many assignments at once will certainly overwhelm some of your
students. You are also very likely not the only lecturer or teacher
students have that will do this; a recent survey among the students of
the University of Klagenfurt has also pointed out that all students,
independent of their chosen curriculum, feel that they have more to do
nowadays than before moving classes online. Try even more than usual
to assign a realistic amount of work to them – and keep in mind that
due to the current situation, some of your students might be under
severe psychological stress. People they care about or depend on might
have even lost their jobs and/or be sick. For the very same reason, it
is not a bad idea to be rather lenient when it comes to assignments
your students have to hand in: you might get more late submissions
than usual – and maybe also fewer submissions in total.</p>
<p>Several students I have spoken to also asked me to keep my online
lectures in the same time slots as they would be usually – because it
provides a bit of rhythm and structure to their chaotic days. In
addition, I still recommend recording your sessions and making the
recordings available to the students as not all of them might be able
to attend the regular times due to care duties or other reasons.</p>
<p>Obviously, everyone will handle these extraordinary times in a
different way. Neither teachers nor students should forget that this
situation is new for everyone. Remember to show understanding if
things do not immediately work out as planned. Feel free to try out
some of my recommended software – or use something entirely different:
whatever works, works!</p>For some reason, my students this semester are happy with what I have done to move my classes to online formats (which, of course, was neccessary due to COVID-19). A friend asked me to write an article containing my views and recommendations for online teaching for a magazine, resulting in the text below. The article did not appear yet – but as soon as it does, I’ll update this blog entry with a link to it.Workshops @ BRG Viktring: Von Büchern, Tauben und den Türmen von Hanoi2018-10-12T05:00:00-05:002018-10-12T05:00:00-05:00https://benjamin-hackl.at/blog/2018/10/workshops-viktring<p>Es war mir eine große Freude, wieder einmal in meine alte Schule, dem
<a href="http://www.brg-viktring.at">Bundesrealgymnasium Klagenfurt-Viktring</a> zurückzukehren um
Mathematik-Workshops mit allen siebenten Klassen abzuhalten.</p>
<p><img src="/downloads/img/2018-10-11_workshop-viktring.jpg" class="img-fluid" /></p>
<p>Die Workshops hatten das Ziel, die Schülerinnen und Schüler auf der einen Seite
auf eine Reise durch mathematische Teilgebiete mitzunehmen, welche im Schulunterricht
aufgrund der strikten Lehrpläne wenig oder keinen Platz finden – und zugleich
Inspiration für Themen für die verpflichtenden Vorwissenschaftlichen Arbeiten zu bieten.</p>
<p>Die Unterlagen zum Workshop, also die Folien sowie die zugehörigen Übungen, sind
auf <a href="/talks/">meiner Vortrags-Seite</a> zu finden.</p>Es war mir eine große Freude, wieder einmal in meine alte Schule, dem Bundesrealgymnasium Klagenfurt-Viktring zurückzukehren um Mathematik-Workshops mit allen siebenten Klassen abzuhalten.Talk @ AofA18: Counting Ascents in Generalized Dyck Paths2018-07-02T02:00:00-05:002018-07-02T02:00:00-05:00https://benjamin-hackl.at/blog/2018/07/aofa18-uppsala<p>Last week I participated at <a href="http://math.uu.se/aofa2018">AofA18</a> in Uppsala, Sweden
and gave a talk on Friday.</p>
<p>The slides can be found on my <a href="/talks/">Talks page</a>.</p>Last week I participated at AofA18 in Uppsala, Sweden and gave a talk on Friday.