Consider a curve given by the function $f(x)$ on the interval $[0,1]$ with the property $f(0)=f(1)=0$ and $f(x) > 0$
everywhere else. The length of the curve is $l \le 0$. What curve will have the maximum area under the function?

We want to maximize the area functional:
$$
S[f] = \int_0^1 f(x) d x
$$
subject to the constraint
$$
A[f] = \int_0^1 \sqrt{1+f'(x)^2} dx = l
$$
So we must extremize the modified functional:
$$
\tilde S[f, \lambda] = \int_0^1 \left(f(x)+\lambda \sqrt{1+f'(x)^2}\right) d x
$$
The Euler-Lagrange equations
$$
{\delta \tilde S\over\delta f(x)} - {d\over d x} {\delta \tilde S\over\delta f'(x)} = 0
$$
become
$$
1-{d\over d x}\left(\lambda {f'(x)\over \sqrt{1+f'(x)^2}}\right) = 0
$$
Integrating:
$$
x-\lambda {f'(x)\over \sqrt{1+f'(x)^2}} = c_1
$$


```
import sympy.interactive
sympy.interactive.init_printing()
```

Let's assume $c_1 = 0$ for now...


```
from sympy import var, Symbol, Function, sqrt, solve, integrate, simplify, refine, Q, python, Derivative, Abs, Id, powsimp
var("x c1")
lam = Symbol("lambda")
f = Function("f")
L = f(x) + lam*sqrt(1 + f(x).diff(x)**2)
eq0 = L.diff(f(x)) - Derivative(L.diff(f(x).diff(x)), x)
eq0
```


```
# integrate can't handle it directly (it will work in the next release)
# eq = integrate(eq0, x)
eq = x - lam * f(x).diff(x) / sqrt(1+f(x).diff(x)**2) #- c1
eq
```


```
sqrt(f(x)).diff(f(x))
```


```
dfx = solve(eq, f(x).diff(x))[1]
dfx
```


```
fx = integrate(dfx, x)
fx
```


```
fx = simplify(fx)
fx
```


```
fx = refine(fx, Q.positive(x))
fx
```


```
refine(fx, Q.positive(lam**2-x**2))   # Unfortunately does not work...
```




$$\frac{- \lambda^{2} + x^{2}}{\sqrt{\lvert{\lambda^{2} - x^{2}}\rvert}}$$




```
-refine(simplify(-fx), Q.positive(lam**2-x**2))
```




$$- \frac{\lambda^{2} - x^{2}}{\sqrt{\lvert{\lambda^{2} - x^{2}}\rvert}}$$



So the solution is $f(x) = -\sqrt{\lambda^2 - x^2}$. The minus sign should not be there, it probably got in at some point...


```

```

5e330c10472300cfeb75f8f32f734f86acf1b637
ipynb
Jupyter Notebook
tutorial_exercises/Variation with Lagrange multipliers.ipynb
certik/scipy-2013-tutorial
26a1cab3a16402afdc20088cedf47acd9bc58483
BSD-3-Clause
2015-02-28T08:53:05.000Z
2021-12-05T05:37:59.000Z
sympy/Variation with Lagrange multipliers.ipynb
certik/scipy-in-13
418c139ab6e1b0c9acd53e7e1a02b8b930005096
BSD-3-Clause
2021-04-17T15:05:46.000Z
2021-04-17T15:05:46.000Z
sympy/Variation with Lagrange multipliers.ipynb
certik/scipy-in-13
418c139ab6e1b0c9acd53e7e1a02b8b930005096
BSD-3-Clause
2015-03-11T00:25:21.000Z
2021-08-25T14:52:40.000Z
Qwen/Qwen-72B
1. YES
2. YES