This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Directional derivative of function


df = fndir(f,y)


df = fndir(f,y) is the ppform of the directional derivative, of the function f in f, in the direction of the (column-)vector y. This means that df describes the function Dyf(x):=limt0(f(x+ty)f(x))/t.

If y is a matrix, with n columns, and f is d-valued, then the function in df is prod(d)*n-valued. Its value at x, reshaped to be of size [d,n], has in its jth "column" the directional derivative of f at x in the direction of the jth column of y. If you prefer df to reflect explicitly the actual size of f, use instead

df = fnchg( fndir(f,y), 'dim',[fnbrk(f,'dim'),size(y,2)] );

Since fndir relies on the ppform of the function in f, it does not work for rational functions nor for functions in stform.


For example, if f describes an m-variate d-vector-valued function and x is some point in its domain, then, e.g., with this particular ppform f that describes a scalar-valued bilinear polynomial,

f = ppmak({0:1,0:1},[1 0;0 1]); x = [0;0];
[d,m] = fnbrk(f,'dim','var');
jacobian = reshape(fnval(fndir(f,eye(m)),x),d,m)

is the Jacobian of that function at that point (which, for this particular scalar-valued function, is its gradient, and it is zero at the origin).

As a related example, the next statements plot the gradients of (a good approximation to) the Franke function at a regular mesh:

xx = linspace(-.1,1.1,13); yy = linspace(0,1,11);
[x,y] = ndgrid(xx,yy); z = franke(x,y);
pp2dir = fndir(csapi({xx,yy},z),eye(2));
grads = reshape(fnval(pp2dir,[x(:) y(:)].'),...

Here is the resulting plot.


The function in f is converted to ppform, and the directional derivative of its polynomial pieces is computed formally and in one vector operation, and put together again to form the ppform of the directional derivative of the function in f.

See Also

| | |

Was this topic helpful?