Search Knowledge

© 2026 LIBREUNI PROJECT

Calculus & Analysis / Overview

Calculus of Variations

Calculus of Variations

In standard calculus, we find a number xx that minimizes a function f(x)f(x). In the Calculus of Variations, we find a function y(x)y(x) that minimizes an integral J[y]J[y], called a Functional.

J[y]=x1x2L(x,y,y)dxJ[y] = \int_{x_1}^{x_2} L(x, y, y') dx

This is the math behind “nature is lazy”: physics always chooses the path that minimizes “Action.”

The Euler-Lagrange Equation

To find the function y(x)y(x) that makes J[y]J[y] stationary (a minimum or maximum), we solve the Euler-Lagrange Equation:

Lyddx(Ly)=0\frac{\partial L}{\partial y} - \frac{d}{dx} \left( \frac{\partial L}{\partial y'} \right) = 0

Famous Problems

1. The Geodesic

What is the shortest path between two points? In flat space, the Euler-Lagrange equation tells us it is a straight line. On a curved surface (like Earth), it is a Great Circle.

2. The Brachistochrone

What shape of a wire allows a bead to slide from AA to BB in the shortest amount of time under gravity? Hint: It is not a straight line. It is a Cycloid (the path traced by a point on a rolling wheel).

3. Fermat’s Principle

Light travels between two points along the path that takes the least time. This principle alone allows us to derive Snell’s Law of refraction and the law of reflection.

python
1import numpy as np
2 
3# Let's compare the time taken for a bead to slide down a straight line
4# vs. a simple parabola (approximation of a cycloid)
5g = 9.81
6h = 10.0 # Height
7L = 10.0 # Horizontal distance
8 
9# Straight line path
10time_line = np.sqrt(2 * (L**2 + h**2) / (g * h))
11 
12# A curved path (e.g. y = x^2/10) actually allows the bead to pick up
13# speed faster at the start, potentially reducing total time.
14print(f"Time for straight line: {time_line:.2f}s")
15print("Curved paths allow the object to trade potential energy for kinetic energy")
16print("earlier in the run, resulting in a faster average velocity.")
17 

Use Cases

  1. Classical Mechanics: Formulating the “Lagrangian” to find equations of motion.
  2. Structural Engineering: Finding the shape of a bridge that minimizes stress.
  3. Machine Learning: Variational Inference and optimizing neural network weights over a continuous space.

Exercises

In the Calculus of Variations, what is a 'Functional'?

The Euler-Lagrange equation is to functionals what _____ is to regular functions.

Why does light bend when it enters water (Refraction)?

Next Module Complex Analysis