# Calculus of variations condition

Given this:

$$\int_0^1\left(\frac{1}{2}y'^2+yy'+y'+y\right)dx$$

where

$$y(0)=1$$

I'm to show that the extremal can be found by imposing this condition:

$$y'+y+1=0$$

at $x=1$

Beltrami's identity gives:

$$\frac{d}{dx}\left(y'\left(y'+y+1\right)-\left(\frac{1}{2}y'^2+yy'+y'+y\right)\right)=0$$

So

$$\frac{d}{dx}\left(\frac{1}{2}y'^2-y\right)=0$$

which doesn't appear to give me the condition I need.

If I try the Euler-Lagrange equation, I get something nearer:

$$\frac{d}{dx}\left(y'+y+1\right)-\left(y'+1\right)=0$$

So

$$\left(y'+y+1\right)|_{x=1}=\left(y+x\right)|_{0}^{1}+\left(y'+y+1\right)|_{x=0}$$

$$\left(y'+y+1\right)|_{x=1}=y(1)+y'(0)+2$$

The LHS is what I'm looking for, but I don't see how to make the RHS be $0$. How do I show the required condition?

When deriving the Euler-Lagrange equation you take variations of $y$. Let $h$ be a variation. Because $y(0)=1$ is fixed, we have $h(0)=0$ for the variation. However, $h(1)$ can be arbitrary. Then $$\int_0^1 y'h' + y'h + yh' + h' + h \,dx = 0$$ After we integrate by parts, we obtain $$(y'+y+1)h\big|_0^1 + \int_0^1 (-y'' +1)h \, dx = 0\,,$$ and so the Euler-Lagrange equation is $$y'' = 1\,,$$ together with the boundary condition $$y'(1)+y(1)+1 = 0\,.$$

• Thanks. How did you get from $y''=1$ to $y′(1)+y(1)+1=0$? I see that $y=\frac{x^2}{2}+cx+1$, but don't see how to get the equation from there. – Number 34 Mar 16 '17 at 22:55
• You get $y''=1$, because the integral has to be zero for all $h$ and hence the integrand has to be zero as well. The other condition comes from the boundary terms. You have $h(0)=0$, because of the boundary condition $y(0)=1$, but $h(1)$ can be arbitrary. Hence $y'+y+1|_1 = 0$. – Martins Bruveris Mar 16 '17 at 22:59

The following SymPy script

from sympy import *

x = Symbol('x')
y = Function('y')(x)

# define Lagrangian
L = 0.5*(Derivative(y,x))**2 + y*Derivative(y,x) + Derivative(y,x) + y

# Euler-Lagrange equation
print euler_equations(L,y,x)


produces

[Eq(-1.0*Derivative(y(x), x, x) + 1, 0)]


Thus, the Euler-Lagrange ODE is $y'' = 1$. Integrating twice, we obtain the family of solutions

$$y (x) = c_0 + c_1 x + \frac{x^2}{2}$$

From $y (0) = 1$, we obtain $c_0 = 1$. To determine $c_1$, more information is needed.