$ \def\Vec#1{\mathbf{#1}} \def\vt#1{\Vec{v}_{#1}(t)} \def\v#1{\Vec{v}_{#1}} \def\vx#1{\Vec{x}_{#1}} \def\av{\bar{\Vec{v}}} \def\vdel{\Vec{\Delta}} $

Harald Kirsch

about this blog
Image Stitch App



Euler-Lagrange Equation

$$\def\R{\mathbb{R}} \def\C{\mathcal{C}} \def\ge{g_\epsilon} $$

First a Rant about Notation Abuse

Every time I had a look at proofs of the Euler Lagrange Equation in the past I stumbled over certain steps which looked weird. The ones that put me off most involve the notation of partial derivatives like

\begin{equation*} \frac{\partial L}{\partial f}(x,f(x),f'(x)) \; \text{and}\; \frac{\partial L}{\partial f'}(x,f(x),f'(x)), \end{equation*}

which are also used in the above mentioned Wikipedia article. In conjunction with mentions of "calculus of variations" I thought, wow, how can a function $L$ have a derivative relative to a function $f$ or even $f'$. What kind of concept is this? As a software devloper trained in strongly typed languages, the $df$ in the denominator just did not make any sense at all.

Meanwhile I realised that this is just a silly abuse of notation and $\partial L/\partial f$ denotes the partial derivative of $L$ with regard to its second parameter. I hate it! If we have, for example, $L(x, 3x^2 + px, 6x+p)$ how's that written then? Do we write $\partial L/\partial(3x^2 + px)$? Nonsense.

For the rest of this text, mainly written for myself to come back here and see the derivation in a way I understand it, I try to be as exact as possible about notation. For the partial derivative of a function $L$ of $n$ arguments I'll write $\partial_i L$ for $1\leq i\leq n$. In particular for $n=1$, $\partial_1 L$ has the exact same meaning as $L'$. The benefit of this notation is that it does not rely on the actual parameters, whether $x$ or $x^\mu$ or $f'$, it does not matter, the meaning is well defined.

So what is the Euler-Langrange Equation?

Problem Statement

A functional is a map from a vector space to the underlying field. For the vector space we have here the sufficiently often continuously differentiable functions on $\R$, say $\C^2(\R, \R)$. Let $J:\C^2(\R,\R)\to R$ be a functional mapping functions to values in $\R$ defined as $$ J(f) = \int_a^b L(x, f(x), f'(x)) dx $$ where $L:\R^3\to\R$ is sufficently often continuously differentiable.

Now you can ask which function $f$ would make $J$ minimal or maximal at least in a sufficiently defined neighbourhood of $f$. To be fair, the Euler-Lagrange Equation does not help to find minimizing or maximizing functions $f$ but rather one such that any sufficiently small variation of $f$ either increases of decreases the value $J(f)$.

The trick employed is to change the problem into one about a function $\phi:\R\to\R$ the derivative $\partial_1\phi=\phi'$ of which shall be zero.

First we introduce a function $\eta:[a,b]\to\R$ such that $\eta(a)=\eta(b)=0$ and then define $\ge:\R\to\R$ as $\ge(x) = f(x)+\epsilon\eta(x)$. We see that $f(x) = g_0(x)$. With these definitions we now define our $\phi$ as $$ \phi(\epsilon) = J(\ge) = \int_a^b L(x, \ge(x), \ge'(x)) dx . $$

Note how $\phi(0) = J(f)$, so if we manage to find an $f$ such that $\phi'(0)=0$ then $\phi(0)$ is extremal or a saddle point and so should be $J(f)$ for small variations of $f$ as implemented by $\ge$.


Finding $\phi'(0)=0$ is mostly elementary calculus on multi parameter functions with one nice lemma thrown in at the end for good. We want

$$ 0 = \phi'(\epsilon) = \frac{d}{d\epsilon} \int_a^b L(x, f(x)+\epsilon\eta(x), f'(x)+\epsilon\eta'(x)) dx $$ We may pull the derivative into the integral to get

$$ 0 = \int_a^b \frac{d}{d\epsilon} L(x, f(x)+\epsilon\eta(x), f'(x)+\epsilon\eta'(x)) dx . $$

Now comes the part to use non-weird notation for the derivatives of $L$. $L$ is a function from $\R^3$ to $\R$ and it is applied to the function $H: \R^2\to\R^3$ defined as

$$ H(\epsilon, x) = \begin{pmatrix}x \\ f(x)+\epsilon\eta(x) \\ f'(x)+\epsilon\eta'(x))\end{pmatrix}. $$

So we can write: \begin{align*} \frac{d}{d\epsilon} L(H(\epsilon, x)) &= ((\partial_1, \partial_2, \partial_3)L)(H(\epsilon, x)) \cdot \frac{d}{d\epsilon} H(\epsilon, x)\\ &\phantom{=}\scriptstyle \text{(row vector times a column vector)}\\ &= ((\partial_1, \partial_2, \partial_3)L)(H(\epsilon, x)) \cdot \frac{d}{d\epsilon} \begin{pmatrix}x \\ f(x)+\epsilon\eta(x) \\ f'(x)+\epsilon\eta'(x))\end{pmatrix} \\ &= ((\partial_1, \partial_2, \partial_3)L)(H(\epsilon, x)) \cdot \begin{pmatrix}0 \\ \eta(x) \\ \eta'(x) \end{pmatrix} \\ &=(\partial_2 L)(H(\epsilon, x))\cdot\eta(x) + (\partial_3 L)(H(\epsilon, x))\cdot\eta'(x) \end{align*}

The latter term of the sum can be integrated by parts. \begin{align*} \int_a^b (\partial_3 L)(H(\epsilon, x))\cdot\eta'(x) dx &= (\partial_3 L)(H(\epsilon, x))\cdot\eta(x)\Bigr\vert_a^b - \int_a^b \ \frac{d}{dx}\Bigl[ (\partial_3 L)(H(\epsilon, x)) \Bigr]\eta(x) dx \\ &= - \int_a^b \frac{d}{dx} \Bigl[(\partial_3 L)(H(\epsilon, x))\Bigr]\eta(x) dx \end{align*} The last line follows because $\eta(a)=\eta(b)=0$. Now we can pick up the full integral from above again which we want to see being zero.

\begin{align*} 0 &= \int_a^b \frac{d}{d\epsilon} L(H(\epsilon, x)) dx \\ &=\int_a^b \left[(\partial_2 L)(H(\epsilon, x)) - \frac{d}{dx} (\partial_3 L)(H(\epsilon, x))\right]\eta(x) dx \end{align*}

Since $\eta$ can be arbitrarily chosen, the integral can only be zero if the part inside the brackets is a constant zero. This is called the fundamental lemma of the calculus of variations. Therefore, what we need is

$$ 0 = (\partial_2 L)(H(\epsilon, x)) - \frac{d}{dx} (\partial_3 L)(H(\epsilon, x)) $$ and in particular, see where we started from, for the case $\epsilon=0$, which brings us straight to the Euler-Lagrange Equation:

$$ \boxed{0 = (\partial_2 L)(x, f(x), f'(x)) - \frac{d}{dx} (\partial_3 L)(x,f(x), f'(x))} $$


GitHub introduces 2FA for everyone

Recently I got an email from GitHub that everyone is shortly forced to use two factor authentication (2FA). Everyone obvious includes me. As the second factor, apart from the normal password, they provide what is called time-base one-time password (TOTP). As can be expected these days, they suggest having an app on the phone that can do it. And indeed, checking the app stores, a whole armada of apps advertise to provide it. Hmmpf, yet another app. What does it actually do?

TOTP as second factor in very simple terms

As I understand it, the whole process in actually quite trivial:

  1. The website, in this case GitHub, presents you with a secret. I strongly assume and hope that it is specific to your account and not shared between accounts.
  2. You tell the app this secret.
  3. The app does its best to store the secret savely.
  4. When logging in to the website, after providing the normal, old-fashioned password, the second factor comes into play. The website wants you to ask the app for a one time password to enter. You ask the app, you get a few digits or characters, enter them much like a second password, and if the website verifies it as correct, you are logged in.

Let me comment and explain some of the steps above:

The Secret

This is, no surprise, just a sequence of characters. The website presents it as QR code or even lets you just type it into the app.

Storing the Secret Savely

I didn't try any specific app, but it is likely not much different from banking apps which require their own password on top of the mobile phones password or authentication. The weirdest thing is the strong suggestion to use a cloud based app which stores the secret, of course secured by yet another password of yours, on someone else's computer (aka cloud). Well, maybe these days it does not really matter any more. The storage on your phone is as open to your phone's app store owner as the cloud itself, I guess. So whether the app encrypts the secret on the phone's storage or into a cloud storage is very much the same when it come to who can extract the encrypted data when they want to try to decrypt it. Cloud storage owner, app store owner — what is the difference?

Insofar the statement that cloud storage is still available if you lose your phone may be a half valid point.

Time Based Password

This is probably the most interesting part, if anything. Read more details on the Internet, but this is the rough procedure: Use the secret together with the current time with, say, minute resolution in a fixed time zone, UTC, to create a hash value of 6 or more digits. That's the one time password. Provide it to the server which does the same with the secret assigned to you and the current time and compare the outcome. For more convenience and allow slighty deviating clocks, the previous and the next minute may be valid as well.

I don't want no reeking app

Yes, apps accrue by the dozens on mobile phones these days. Ehem, not on mine, really. And for the extra trivial shit described above, why another app? And when I am in front of the desktop, there is enough computer availabe right in front of me. And the phone may actually be in another room. Yes, believe it or not, sometimes I don't have it in arm's length reach. Must be old age, born in the previous millenium :-) So:

% apt-cache search totp

Turns out there is otpclient. And it stores the secret in an encrypted database. And it asks me where I want to have this database stored (think external USB drive). And it can read the presented QR code in several ways, like screenshot or clipboard. And it just works.



Fakten zur Energie

Bei der Diskussion um erneuerbare Energien ist es immer gut einige Fakten und Größenordnungen vor Augen zu haben. Insbesondere sind Meldungen in der Presse immer einordnungsbedürftig. Ist ein Jubelartikel zum Windpark mit 10MW zum Jubeln? Nein ist er nicht. Eine einzelne Windkraftanlage hat schon zwischen 5 und 18MW (Frühjahr 2023).

Große Windkraftanlage erhältlich "von der Stange", Frühjahr 2023

  • offshore 15MW, z.B. Vestas V236-15.0MW
  • offshore 18MW, CSSC Haizhuang H260-18.0

Jährlicher Energieverbrauch in Form von Strom in Deutschland

  • 500 TWh in 2022
  • Anstieg über die nächsten Jahr erwartet wegen Elektrifizierung auf 1000 TWh.


Energy Dome, Energiespeicher per Umsetzung zwischen flüssigem und gasförmigen CO$_2$.

  • Errichtung: 220€/kWh für
  • Kapazität und Leistung: 20MW$\times$10h

Vanadium Redox Flow

  • Errichtung: 430€/kWh
  • Kapazität und Leistung: 7MW$\times$4.3h