Potential energy of a bent spring What is the potential energy for a large spring that is bent into an arbitrary shape? The solution should be of the form $V=\int (...) ds $

EDIT:
I have reduced this problem to the problem of the 2D elastica, or a bent elastic rod (no stretching or twisting). (Following Equation 10 in https://www2.eecs.berkeley.edu/Pubs/TechRpts/2008/EECS-2008-103.pdf and many other sources):
The energy for this system is $$E[\theta(s)] = \int_0^Lds \frac1{R^2} =\int_0^Lds \left(\frac{d \theta}{ds}\right)^2 \tag{1}$$
Where $R$ is the radius of curvature, $R d\theta = ds$.
Varying the energy using Euler-Lagrange equations gives $\frac{d\theta}{ds}=constant$. This means the solution is just some section of a circle. This can't be right and does not allow for a positional boundary condition on the endpoint.
To fix this issue, consider Equation 22 of https://www2.eecs.berkeley.edu/Pubs/TechRpts/2008/EECS-2008-103.pdf, which seems to be the form of energy I am looking for, and allows for two additional positional boundary conditions for the endpoint.
$$\theta'' + \lambda_1 \cos(\theta) +\lambda_2 \sin(\theta)=0\tag{2}$$
An outline/resources on the solution of (2) would be appreciated (assuming this is the equation I am looking for!).
Also, (2) reduces to (1) in the limit that $\lambda_1=\lambda_2=0$. Is it ever physically meaningful to consider (1) or is (1) just a completely incorrect/meaningless equation?
 A: In general, you have to find the potential for individual components of the spring and sum them up over the trajectory.[Integrate]
Remember you do not have to increase k as you are not physically disconnecting the components.
And the equation of the shape matters [because through this you will have the displaced height from the equilibrium]
My approach! (Based on your constrained process) is given below,
$$V=\frac{1}{2}ky^{2}$$
$$dV=kydy$$
$$dy=\frac{dV}{ky}----(I)$$
let assume the equation of the shape is given by y=f(x), y is the vertical displacement from the equilibrium.
$${\dot{y}}=f'(x)=\frac{dy}{dx}$$
Thus,
$$dy=f'(x)dx----(II)$$
From eq-(I) & (II)
$$dx=\frac{dV}{kf(x)f'(x)}$$
As we know,
$$ds=\sqrt{(dx)^{2}+(dy)^{2}}$$
Substituting dx and dy,
$$ds=\frac{dV}{kf(x)}\sqrt{1+\left(\frac{dy}{dx}\right)^{-2}}$$
That implies,
$$dV=\frac{ky}{\sqrt{1+(\dot{y})^{-2}}}ds$$
Therefore,
$$V=k\int_{s_{1}}^{s_{2}}\left(\frac{y}{\sqrt{1+(\dot{y})^{-2}}}\right)ds$$

A: I think you are asking about  what is called an an elastica.
The energy is given by
$$
E=\int \frac 12  (\lambda \kappa^2 + \nu \tau^2) ds
$$
where $s$ is the arc length, $\lambda$ and $\nu$ are constants. The functions  $\kappa$ and $\tau$ are the curvature and torsion of the curve ${\bf r}(s)$ that are defined by the Serret-Frenet equations:
$$
\frac{d{\bf t}}{ds}=\kappa {\bf n}\\
\frac{d{\bf n}}{ds}=-\kappa {\bf n}+\tau {\bf b}\\
\frac{d{\bf b}}{ds}= - \tau{\bf n}
$$
Here
$$
{\bf t}= \frac{d{\bf r}}{ds}
$$ is the unit tangent, and the normal ${\bf n}$ and binormal ${\bf b}$  vectors are implicitly defined by these equations.
There is a large literature --- starting from Euler who defined the notion of an elastic rod --- on these equations and their solutions
A: I am not sure whether I have understood your question correctly, but if it is going to help you, I could outline a derivation of equation (2), which after the application of a trigonometric identity, can be converted into pendulum's equation.
Fix a 2D inertial, orthonormal coordinate system $O\,\vec{i}\,\vec{j}$
Parametrize the curve by arc-length:
$$\vec{r}(s) = x(s)\,\vec{i} \,+\, y(s)\,\vec{j}$$ where $s \in [0, L]$ is the arc-length parameter. An arc-length parametrization is characterized by the identity
$$\left\|\frac{d\vec{r}}{ds}\right\|^2 \,=\,\Big(\,\frac{dx}{ds}\,\Big)^2+\, \Big(\,\frac{dy}{ds}\,\Big)^2 \,=\, 1$$ which is a constraint.
Then, after denoting by $R = R(s)$ radius of curvature at distance $s$ from the origin of the curve, $$\frac{1}{R^2} \,=\, \left\|\frac{d^2\vec{r}}{ds^2}\right\|^2 
 \,=\, \left(\frac{d^2x}{ds^2}\right)^2 \,+\,  \left(\frac{d^2y}{ds^2} \right)^2$$ The length of the curve is fixed, and on top of that usually the endpoints are also fixed: one end is at the origin $O$ of the coordinate system, the other end is at positive coordinate position $(a, \,b) \,=\, a\,\vec{i} + b\,\vec{j}$
which yields the constraints
$$\vec{r}(0) \,=\, \vec{0}\,\,\text{ and }\,\,\vec{r}(L) \,=\, a\,\vec{i} + b\,\vec{j}$$
Consequently, the constraint Lagrangian is
$$\int_0^{L} \, \frac{1}{2}\,\left\|\frac{d^2\vec{r}}{ds^2}\right\|^2\,ds \,+\,  \lambda \, \big(\,\vec{i}\cdot\vec{r}(L) - a\,\big)  \,+\,  \mu \, \big(\,\vec{j}\cdot\vec{r}(L) - b\,\big)\,+\, \nu\,\left(\,\left\|\frac{d\vec{r}}{ds}\right\|^2 - 1 \,\right)$$ which, by Newton-Leibniz, can be written as
$$\int_0^{L} \, \frac{1}{2}\,\left\|\frac{d^2\vec{r}}{ds^2}\right\|^2\,ds \,+\,  \lambda \, \Big(\,\int_{0}^{L}\, \Big(\, \vec{i}\cdot\frac{d\vec{r}}{ds}\,\Big)\,ds - a\,\Big)  \,+\,  \mu \, \Big(\,\int_{0}^{L}\, \Big(\, \vec{j}\cdot\frac{d\vec{r}}{ds}\,\Big)\,ds - b\,\Big)\,+\, \nu\,\left(\,\left\|\frac{d\vec{r}}{ds}\right\|^2 - 1 \,\right)$$
an then
$$\int_0^{L} \,\left(\, \frac{1}{2}\,\left\|\frac{d^2\vec{r}}{ds^2}\right\|^2 \,+\,  \lambda\, \Big(\, \vec{i}\cdot\frac{d\vec{r}}{ds}\,\Big) \,+\,  \mu \, \Big(\, \vec{j}\cdot\frac{d\vec{r}}{ds}\,\Big)\,\right)\,ds\,+\, \nu\,\left(\,\left\|\frac{d\vec{r}}{ds}\right\|^2 - 1 \,\right) \,-\, \lambda\,a - \mu\, b$$ where the constant terms can be removed, yielding the constraint Lagrangian
$$\int_0^{L} \,\left(\, \frac{1}{2}\,\left\|\frac{d^2\vec{r}}{ds^2}\right\|^2 \,+\,  \lambda\, \Big(\, \vec{i}\cdot\frac{d\vec{r}}{ds}\,\Big) \,+\,  \mu \, \Big(\, \vec{j}\cdot\frac{d\vec{r}}{ds}\,\Big)\,\right)\,ds\,+\, \nu\,\left(\,\left\|\frac{d\vec{r}}{ds}\right\|^2 - 1 \,\right)$$ In order the reduce the order of the derivatives, substitute
$$\vec{u}(s) \,=\, \frac{d\vec{r}}{ds}(s)$$
and the Lagrangian is now
$$\int_0^{L} \,\left(\, \frac{1}{2}\,\left\|\frac{d\vec{u}}{ds}\right\|^2 \,+\,  \lambda\, \Big(\, \vec{i}\cdot\vec{u}\,\Big) \,+\,  \mu \, \Big(\, \vec{j}\cdot\vec{u}\,\Big)\,\right)\,ds\,+\, \nu\,\left(\,\left\|\vec{u}\right\|^2 - 1 \,\right)$$
One can easily remove the last holonomic constraint by introducing $\theta = \theta(s)$ such that
$$\vec{u}(s) \,=\, \cos\theta(s)\,\vec{i}\,+\, \sin\theta(s)\,\vec{j}$$ which turns the Lagrangian into
$$\int_0^{L} \,\left(\, \frac{1}{2}\,\left(\,\frac{d\theta}{ds}\,\right)^2 \,+\,  \lambda\, \cos(\theta) \,+\,  \mu \, \sin(\theta)\,\right)\,ds$$
The Euler-Lagrange equation is
$$\frac{d^2\theta}{ds^2}\,=\, -\,\lambda \,\sin(\theta) \,+\, \mu\, \cos(\theta)$$
By certain trigonometric identities, one can find $\omega$ such that if one makes the substitution $\varphi \,=\, \theta + \omega$ the equation becomes something like
$$\frac{d^2\varphi}{ds^2} \,=\, -\, \Big(\,\sqrt{\lambda^2 + \mu^2}\,\Big)\,\cos(\varphi)$$
