functionalDerivative

Functional derivative

Description

example

D = functionalDerivative(f,y) returns the Functional Derivative of the functional F=f(x,y(x),y'(x)...)dx with respect to the function y = y(x), where x represents one or more independent variables. If y is a vector of symbolic functions, functionalDerivative returns a vector of functional derivatives with respect to the functions in y, where all functions in y must depend on the same independent variables.

Examples

Find Functional Derivative

Find the functional derivative of the function given by f(y)=y(x)sin(y(x)) with respect to the function y.

syms y(x)
f = y*sin(y);
D = functionalDerivative(f,y)
D(x) =
sin(y(x)) + cos(y(x))*y(x)

Find Functional Derivative of Vector of Functionals

Find the functional derivative of the function given by H(u,v)=u2dvdx+vd2udx2 with respect to the functions u and v.

syms u(x) v(x)
H = u^2*diff(v,x)+v*diff(u,x,x);
D = functionalDerivative(H,[u v])
D(x) =
 2*u(x)*diff(v(x), x) + diff(v(x), x, x)
 diff(u(x), x, x) - 2*u(x)*diff(u(x), x)

functionalDerivative returns a vector of symbolic functions containing the functional derivatives of H with respect to u and v, respectively.

Find Euler-Lagrange Equation for Spring

First find the Lagrangian for a spring with mass m and spring constant k, and then derive the Euler-Lagrange equation. The Lagrangian is the difference of kinetic energy T and potential energy V which are functions of the displacement x(t).

syms m k x(t)
T = sym(1)/2*m*diff(x,t)^2;
V = sym(1)/2*k*x^2;
L = T - V
L(t) =
(m*diff(x(t), t)^2)/2 - (k*x(t)^2)/2

Find the Euler-Lagrange equation by finding the functional derivative of L with respect to x, and equate it to 0.

eqn = functionalDerivative(L,x) == 0
eqn(t) =
- m*diff(x(t), t, t) - k*x(t) == 0

diff(x(t), t, t) is the acceleration. The equation eqn represents the expected differential equation that describes spring motion.

Solve eqn using dsolve. Obtain the expected form of the solution by assuming mass m and spring constant k are positive.

assume(m,'positive')
assume(k,'positive')
xSol = dsolve(eqn,x(0) == 0)
xSol =
-C3*sin((k^(1/2)*t)/m^(1/2))

Clear assumptions for further calculations.

assume([k m],'clear')

Find Differential Equation for Brachistochrone Problem

The Brachistochrone problem is to find the quickest path of descent under gravity. The time for a body to move along a curve y(x) under gravity is given by

f=1+y'22gy,

where g is the acceleration due to gravity.

Find the quickest path by minimizing f with respect to the path y. The condition for a minimum is

δfδy=0.

Compute this condition to obtain the differential equation that describes the Brachistochrone problem. Use simplify to simplify the solution to its expected form.

syms g y(x)
assume(g,'positive')
f = sqrt((1+diff(y)^2)/(2*g*y));
eqn = functionalDerivative(f,y) == 0;
eqn = simplify(eqn)
eqn(x) =
diff(y(x), x)^2 + 2*y(x)*diff(y(x), x, x) == -1

This equation is the standard differential equation for the Brachistochrone problem.

Find Minimal Surface in 3-D Space

If the function u(x,y) describes a surface in 3-D space, then the surface area is found by the functional

F(u)=f(x,y,u,ux,uy)dxdy=1+ux2+uy2dxdy,

where ux and uy are the partial derivatives of u with respect to x and y.

Find the equation that describes the minimal surface for a 3-D surface described by the function u(x,y) by finding the functional derivative of f with respect to u.

syms u(x,y)
f = sqrt(1 + diff(u,x)^2 + diff(u,y)^2);
D = functionalDerivative(f,u)
D(x, y) =
-(diff(u(x, y), y)^2*diff(u(x, y), x, x)...
 + diff(u(x, y), x)^2*diff(u(x, y), y, y)...
 - 2*diff(u(x, y), x)*diff(u(x, y), y)*diff(u(x, y), x, y)...
 + diff(u(x, y), x, x)...
 + diff(u(x, y), y, y))/(diff(u(x, y), x)^2...
 + diff(u(x, y), y)^2 + 1)^(3/2)

The solutions to this equation D describe minimal surfaces in 3-D space such as soap bubbles.

Input Arguments

collapse all

Expression to find functional derivative of, specified as a symbolic variable, function, or expression. The argument f represents the density of the functional.

Differentiation function, specified as a symbolic function or a vector, matrix, or multidimensional array of symbolic functions. The argument y can be a function of one or more independent variables. If y is a vector of symbolic functions, functionalDerivative returns a vector of functional derivatives with respect to the functions in y, where all functions in y must depend on the same independent variables.

Output Arguments

collapse all

Functional derivative, returned as a symbolic function or a vector of symbolic functions. If input y is a vector, then D is a vector.

More About

collapse all

Functional Derivative

Consider functionals

F(y)=Ωf(x,y(x),y'(x),y''(x),...)dx,

where Ω is a region in x-space.

For a small change in the value of y, δy, the change in the functional F is

δFδy=ddε|ε=0F(y+εδy)=Ωδf(x)δyδy(x)dx+boundary terms.

The expression δf(x)δy is the functional derivative of f with respect to y.

Introduced in R2015a