TL;DR
A functional derivative tells you how a total quantity changes when you nudge the whole function it depends on, not a single number. Take a functional , such as the integral of over . Its functional derivative is a function with one property: the first-order change in equals for any small wiggle added to . It is the directional derivative idea carried into a space where a direction is a whole function and the dot product is an integral.
Builds on: Calculus of Variations, Directional Derivative · Leads to: Density Functional Theory
Where it's used
Electrons in molecules. The energy of a molecule can be written as a functional (see Calculus of Variations) of the electron density , a function of position in space. Density functional theory says the true density is the one that makes this energy smallest. The functional derivative of the energy with respect to the density gives the potential that the electrons feel, and chemistry codes solve that condition for molecules with many atoms.
Learning a whole function. Some learning methods choose a function, not a parameter vector. Gradient boosting can be read as gradient descent in function space: at each step the model adds a new function that points downhill on the loss, and that downhill direction is a functional gradient.
Sag of a string under load. The stored energy of a stretched string is an integral over its deflection . Setting its functional derivative to zero gives the shape the string settles into. Example 3 below does this calculation.
How it works
Use the simplest functional we can: , which gives one number for each function on . Take and the wiggle , a constant. This toy has no endpoint conditions. We want the rate at which changes as moves in the direction .
- Start with the value. . Check: .
- Nudge the function by . The new function is , and . Check: at this gives , the value from step 1.
- Take the change and divide by . The change is , so the quotient is . Check: with the change is and the quotient is .
- Let go to zero. The quotient goes to . That limit is the directional derivative of at in the direction .
- Find the function that produces this number. Guess and test it: . The two agree. The math section shows where the guess comes from. Check: both sides equal 1.
- Name it. is the functional derivative , and the whole idea is that the directional derivative equals .
flowchart LR A[Function f] --> B[Nudge f by eps times eta] B --> C[Change in J, divided by eps] C --> D[Let eps go to zero] D --> E[Write the limit as the integral of g times eta] E --> F[g is the functional derivative]
- f(x) = x
- f + 0.1 eta
The math
Let be a functional, a rule that gives a number for each function in some class. The functional derivative of at is the function such that, for every smooth wiggle that respects the problem's boundary conditions,
The left side is the directional derivative of in the direction . The right side is the integral of the product of two functions, the function-space version of a dot product.
Step 1 in symbols: the nudge
The function is the original plus a small multiple of the wiggle. In the example, and , so .
Step 2 in symbols: the change
Let . The walkthrough found . A Taylor expansion of at gives this form. The first-order part is the term linear in , here . The directional derivative is exactly this coefficient, because , where stands for terms that shrink faster than .
Step 3 in symbols: the guess is forced
For , differentiating under the integral sign gives
so . The function is unique. Suppose two functions and both work, and let . Then for every admissible . Choose , which is allowed when is smooth: then , so .
Step 4 in symbols: the general integrand
For with fixed endpoints, the derivation in Calculus of Variations gives . Integrate the second term by parts, as in Integration by Parts, with so the boundary term vanishes:
Setting this to zero is the Euler–Lagrange equation. The functional derivative is the general object; the Euler–Lagrange equation is the statement that it vanishes.
Worked examples
Let , with and wiggle .
- Nudge: .
- Square: .
- Integrate: . Check: and .
- Divide the change by : , which goes to as goes to zero.
- Compare with the formula: , and . The values match.
Interpretation: moving toward larger values where is large raises at rate 2 per unit of .
Let , with and wiggle . The wiggle is zero at both ends.
- The formula from the math section gives . For we have , so .
- Compute the first-order change directly: .
- With and , the first term is . Check: .
- The second term is .
- The total is .
- The formula gives . Same answer.
Interpretation: the term was moved onto by integration by parts. That is where the in the formula comes from. Here , so it adds nothing.
A string on is fixed at both ends. Let be its downward deflection, and let a uniform load pull on it. The energy is
where the first term is the stretching energy and the second is the energy released as the load drops.
- Write the integrand as , so and .
- The functional derivative is .
- Set it to zero: . This is the stationary condition.
- Integrate twice: .
- Apply the endpoints. gives . gives , so . Therefore .
- The peak is at : . With the peak is . Check: .
Interpretation: the sag is a parabola, and it grows in proportion to the load.
Try it: the same string carries a load . What is the peak sag?
Answer: . Doubling the load doubles the sag, as the formula says.
Common mistakes and tradeoffs
It is tempting to think a functional derivative is a single number, like an ordinary partial derivative. In fact it is a function of . For it is , which changes from point to point along the interval.
It is tempting to drop the derivative term. In fact for the answer is , not . For , , while alone gives .
It is tempting to think the wiggle must have length 1. In fact the definition takes a limit in , so any works, and scaling scales the answer. The unit-length condition in the Directional Derivative exists so that the answer is a rate per unit distance. A function space has many possible notions of distance, so the definition does not pick one.
It is tempting to forget the endpoint conditions. Integration by parts needs to vanish at the ends, which is why the wiggles must respect the boundary conditions. If it does not, boundary terms appear and the simple Euler–Lagrange form needs extra conditions.
When to use it. Use it when the unknown is a whole function and the objective is an integral, as in energy minimisation and in the physics and chemistry examples above. When not to use it. If the functional is not differentiable, the directional-derivative limit may not exist. Alternative. Replace the function by its values on a grid of points. The functional becomes an ordinary function of variables, and its partial derivatives approximate the functional derivative times the grid spacing. This is how many numerical solvers work.
History
The functional derivative grew out of the calculus of variations, which asks how a total changes under a small change of a whole curve. The problem that started that field was the brachistochrone, the curve of fastest descent, as described in Calculus of Variations. The notation is the one used in physics and chemistry, where energies and actions are integrals of functions. It became central when those fields needed the stationary condition for such energies. Density functional theory is the best-known case: the energy is a functional of the electron density, and its functional derivative gives the potential the electrons feel. The idea caught on because it turns a family of problems into one condition: the functional derivative is zero.
Recap
- A functional takes a whole function and returns a number.
- Nudging by gives a first-order change; its rate is the Directional Derivative of in the direction .
- The functional derivative is the function for which that rate equals for every admissible .
- For , . Setting gives the Euler–Lagrange equation of Calculus of Variations.
Read next: Density Functional Theory, where the functional derivative of the energy gives the potential that electrons feel.
Check yourself
QuestionWrite the defining equation of the functional derivative of J at f, in words and in symbols.Show answer
In words: the rate of change of as moves by , evaluated at , equals the integral of the functional derivative times , for every admissible . In symbols, , where .
QuestionLet . What is at when ?Show answer
The functional derivative is , so it is . At the value is .
QuestionWhy is the functional derivative a function of x rather than a single number, and why is it unique?Show answer
A functional can respond differently to a wiggle at each point, so the sensitivity is a function of position. It is unique because if two functions gave the same integral against every admissible , their difference would satisfy for all . Choosing gives , so .
QuestionA load of pulls on the string of Example 3. What is the peak sag?Show answer
The shape is , and the peak is . With the peak is .