Let’s do some very simple maths. Assume that we are given a *closed* curve $\gamma \subset \mathbb{R}^2$, parametrised via its arc-length $r \in [0,s]$, and two functions $f$ and $g$ defined there. We make the additional assumption that

$$\int_0^s f( r ) dr = 0$$

and we thereby express that the *mean value* of $f$ vanishes. We set

$$h_0(x) = \int_0^x f( r ) dr$$

to be the values of $f$ so far assembled. Since $h_0( 0 ) = h_0( s ) = 0$, $h_0$ takes its absolute minimum at some point in $(0,s)$, so there exists an $a \in (0,s)$ such that

$$\int_0^a f( r ) dr \le \int_0^x f( r ) dr$$

for all $x \in [0,s]$, which may also be written as

$$h_a(x) = \int_a^x f( r ) dr \ge 0~.$$

We now take into account that the curve is closed and see that the function $h_a$ reveals to be

$$h_a(x) = \left\{ \begin{array}{ll} \displaystyle \int_a^x f( r ) dr & x \in (a,s)\\ \displaystyle \int_a^s f( r ) dr +\int_0^x f( r ) dr & x \in (0,a)\end{array} \right.$$

so both $h_0$ and $h_a$ do the same, namely to sum up all values of $f$, but they start from different points on the curve; and as an effect, while $h_0$ may assume negative values on $\gamma$, $h_a$ is always *positive*.

As regards the minimal point, the necessary conditions for $a$ are $f(a) = 0$ (to make $h_0$ stationary) and $f’(a) \ge 0 $ (to make $h_0$ locally minimal).

We now head over to a semi-discretised variant. We pick $n$ random points $r_1 , \ldots , r_n$ on $\gamma$ defining $n$ boundary elements $\gamma_1 , \ldots , \gamma_n$ with arc-lengths $| \gamma_k | = r _{ k + 1 } - r _k$ (of course, $r _1 = 0$ and $r _{n+1} = s$) and we set

$$f _k = \int _{r _k}^{r _{k+1}} f( r )\, dr$$

so that

$$\int_0^x f( r ) \, dr = \int_0^x \left( \sum _{ k = 1}^n \delta( r - r _k )\cdot f _k \right) dr~.$$

Moreover, instead of applying the above to this sum of $\delta$-distributions, we study

$$h_0(x) = \int_0^x \left( f( r ) - g( r ) \right) dr~,$$

with a *strictly positive* function $g$ so that the side-condition $h_0 ( 0 ) = h _0( s ) = 0$ now reads

$$ \sum _{ k = 1}^n f _k = \int_0^s g( r ) dr$$

Basically, the above remains valid for the new case, but some care must be taken as regards the necessary conditions for the minimizer $a$. If $a \notin \{ r _1 , \ldots , r _n \}$, then $g( a ) = 0$ is one of them, what we have excluded, so $a \in \{ r _1 , \ldots , r _n \}$.

Second, if $a=r _k$, then the necessary condition for $h_0$ to be locally *minimal* in $r _k$ now is

$$f _k \ge \int _{r _k}^{r _{k+1}} g( r )\, dr~.$$