IV. Differential equations and advanced analysis
37. Calculus of variations
The app looks for an extremal of a functional J[y] = ∫ F(x, y, y′) dx with the boundary conditions y(a), y(b): it sets up the Euler–Lagrange equation ∂F/∂y − d/dx ∂F/∂y′ = 0 (with the partial derivatives in the steps), shows the first integral of an integrand without y and solves the resulting differential equation by the ODE solver with the boundary conditions and a check. The problem is also a form in the fields Calculus and Physics (Applications).
If the equation has no closed-form solution and F doesn't depend on x, it uses Beltrami's identity and recognizes the known extremals: the brachistochrone (a cycloid, compared with the straight line, with the time of the slide), the catenary and the minimal surface of revolution (two, one or no catenary – Goldschmidt's solution), an isoperimetric problem with a Lagrange multiplier (a circular arc of a given length, a hanging chain). The constants are found numerically. The principle of least action turns a Lagrangian into the equation of motion, for a pendulum with sin θ ≈ θ. An interactive demo – a race of balls along the brachistochrone – is on mathtrace.app under “Try it yourself”.
How to enter it
functional(sqrt(1 + y'^2); y(0) = 0; y(1) = 2) | The integrand and the boundary conditions, separated by semicolons. |
functional(y; y(-1) = 0; y(1) = 0; sqrt(1 + y'^2) = pi) | The constraint ∫ G dx = L as the last item. |
functional(m*x'^2/2 - k*x^2/2; action) | A Lagrangian L = T − V and the word action – the equation of motion. |
Examples
functional(sqrt(1 + y'^2); y(0) = 0; y(1) = 2)


functional(y'^2 + y^2; y(0) = 0; y(1) = 1)


functional(sqrt(1 + y'^2)/sqrt(2*9.81*y); y(0) = 0; y(2) = 1)


functional(y*sqrt(1 + y'^2); y(-1) = 2; y(1) = 2)


functional(y*sqrt(1 + y'^2); y(-2) = 1; y(2) = 1)
functional(y; y(-1) = 0; y(1) = 0; sqrt(1 + y'^2) = pi)


functional(y*sqrt(1 + y'^2); y(-1) = 2; y(1) = 2; sqrt(1 + y'^2) = 3)


functional(m*x'^2/2 - k*x^2/2; action)


functional(m*l^2*θ'^2/2 + m*g*l*cos(θ); action)


Known limitations
- One unknown function and at most its first derivative in the integrand; functionals of several functions or with y″ not yet.
- The known extremals (cycloid, catenary, circular arc) are recognized by the integrand's form; other nonlinear equations stay as the Euler–Lagrange equation.
- The brachistochrone starts at rest – the start point must have y(a) = 0 and the y-axis points down.