I'm thinking of the following question:
Consider a function $f: U\rightarrow\mathbb{R}$ where $U=[0,L_1)\cup(L_1,L]$, and an energy functional $$F=\int_{U}\Big (\frac{\mathrm{d}f}{\mathrm{d}x}\Big)^2\mathrm{d}x.$$ The boundary condition is $f(0)=f(L)=0$. Also, assume $f$ has a jump discontinuity at $x=L_1$, i.e., $f(L_1^-)=-f(L_1^+)=-a$, where $a$ is a constant, and $L_1$ is a variable.
The question is: what is the minimum energy?
Simple answer: the Euler-Lagrange equation on $[0,L_1)$ and $(L_1,L]$ is $$\frac{\mathrm{d}^2 f}{\mathrm{d}x^2}=0,$$ Therefore we have the following solution: $$f(x) = \begin{cases} -\frac{a}{L_1}x, & \text{x$\in [0,L_1)$} \\ -\frac{a}{L-L_1}x+\frac{L}{L-L_1}a, & \text{x$\in (L_1,L]$} \end{cases}$$ Then the energy function $F(L_1)=\frac{a^2}{L_1}+\frac{a^2}{L-L_1}$. Therefore we have the minimum energy $4a^2/L$ when $L_1=L/2$.
Then I tried Fourier series. The Fourier series for the discontinuous solutions are $$ f(x)=\sum_{k=1}^{\infty}\Big[\frac{4a}{k\pi}\cos\frac{k\pi L_1}{L}+\frac{2aL}{(k\pi)^2}\Big(\frac{1}{L-L_1}-\frac{1}{L_1}\Big)\sin\frac{k\pi L_1}{L}\Big]\sin\Big(\frac{k\pi x}{L}\Big),$$ When we substitute this representation into the energy functional, we get infinite energy. In particular,\begin{align} F(L_1=L/2) & =\sum_{k=1}^{\infty}\Big(4a\cos\Big(\frac{k\pi}{2}\Big)\Big)^2\cdot\frac{1}{2L}\\ & =\sum_{k=1}^{\infty}\frac{4a^2}{L}(1+\cos k\pi)~\mathrm{e}^{-\lambda_1 k} & \text{$\lambda_1\to0^+$}\\ & \to\frac{4a^2}{L}\cdot\frac{1}{\lambda_1}\\ \end{align} \begin{align} F(L_1=L/4) & =\sum_{k=1}^{\infty}\Big(4a\cos\Big(\frac{k\pi}{4}\Big)-\frac{16}{3}\frac{a}{k\pi}\sin\Big(\frac{k\pi}{4}\Big)\Big)^2\cdot\frac{1}{2L}\\ & =\sum_{k=1}^{\infty}\frac{4a^2}{L}\Big(1+\cos \Big(\frac{k\pi}{2}\Big)\Big)~\mathrm{e}^{-\lambda_2 k}\\& +\sum_{k=1}^{\infty}\Big(\frac{128a^2}{9L}\frac{1}{(k\pi)^2}\sin^2\Big(\frac{k\pi}{4}\Big)-\frac{64a^2}{3L}\frac{1}{k\pi}\sin\Big(\frac{k\pi}{4}\Big)\cos\Big(\frac{k\pi}{4}\Big)\Big)& \text{$\lambda_2\to0^+$}\\ & \to\frac{4a^2}{L}\cdot\frac{1}{\lambda_2}-\frac{4}{3}\cdot\frac{a^2}{L}\\ \end{align}
It is not surprising that the energies are infinite due to the Gibbs phenomenon. However, it is surprising when we take a look at the energy difference: $$F(L_1=L/4)-F(L_1=L/2)=\Big(\frac{4a^2}{L}\cdot\frac{1}{\lambda_2}-\frac{4a^2}{L}\cdot\frac{1}{\lambda_1}\Big)-\frac{4}{3}\cdot\frac{a^2}{L}$$ While when we use $F(L_1)=\frac{a^2}{L_1}+\frac{a^2}{L-L_1}$, we get $F(L_1=L/4)-F(L_1=L/2)=\frac{4}{3}\cdot\frac{a^2}{L}$. My observation is that when we "ignore" the divergent term, the Fourier series give us the correct absolute value for the energy difference but wrong sign (I have checked for all values of $L_1$). I don't feel like it is a coincidence.
To get the correct value of energy difference, I'm guessing that maybe when we use Fourier series, we introduce a vanishing length scale for the jump discontinuity, and this length scale should be the same whatever the value of $L_1$ is, and somehow $\lambda_1$, $\lambda_2$ are related to it so that $\frac{4a^2}{L}\cdot\frac{1}{\lambda_2}-\frac{4a^2}{L}\cdot\frac{1}{\lambda_1}$ may be some finite number.
My question is whether we can use Fourier series to get the correct value of energy difference.