How to compute the functional derivative with respect to 'f(x)'?

5 views (last 30 days)
The function 'functionalDerivative' that is new in version 6.2 of the Symbolic Math Toolbox fails with the following simple input
>> u = sym('u');
>> fu = symfun(sym('f(u)'), [u]);
>> x = sym('x');
>> fx = symfun(sym('f(x)'), [x]);
>> functionalDerivative(fu, fx)
Error using symfun/privResolveArgs (line 187)
Symbolic function inputs must match.
The result I am expecting in this case is dirac shifted to x (i.e., g(s)=dirac(s - x)).
Am I not using functionalDerivative correctly, or is it not able to generate this result?

Answers (1)

Philip Caplan
Philip Caplan on 17 Apr 2015
The error you are receiving is due to the fact that "fu" and "fx" need to be functions of the same independent variable, otherwise there is nothing to link the two functions and, hence, compute the functional derivative.
For example, assume the second argument passed to "functionalDerivative" is "f(x)" as you have it. Then, a valid first argument would be an expression of "x", "f(x)", "diff(f(x),x)", "diff(f(x),x,x)", etc. Here is an example:
>> syms f(x)
>> g(x) = f(x)^3 + diff(f(x),x,x,x)*diff(f(x), x);
>> functionalDerivative(g(x), f(x))
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!