File Exchange

image thumbnail


version (543 Bytes) by Mukhtar Ullah
Directional derivative

1 Download

Updated 11 Feb 2005

No License

Xpf = dirdiff(X,f,p)

generates directional derivative of symbolic scalar function f at the point p in the direction of symbolic vector X(p). p must be a cell array {p1,p2,} of doubles or symbolic variables.

syms x1 x2 x3 y1 y2 y3
X = [ 2*x3 - x1^2 ; x1^3 - x3^2 ; x2^4 ] ;
f = x1^2 + x2^2 + x3^2 ;
dirdiff(X,f,{2,0,3}) returns Xpf = 3.5777
dirdiff(X,f,{y1,0,0}) returns Xpf = -2*y1^3/(y1^4+y1^6)^(1/2)

Cite As

Mukhtar Ullah (2021). DIRDIFF (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Riccardo Centi

% if F is a surface its directional
% derivative at the point x in the
% direction r can be expressed
% DF(x,r) = D(F(x+a*r,r) - F(x))/da with a = 0

syms a;
syms f1;
f1 = subs(f,x,x + a*r);
Xpdf = subs(diff ((f1-f),a),a,0)

Centi Riccardo

Function directionally derivative can be calcolated faster in the following way

syms a;
syms f1;
f1 = subs(f,x + a*X);
Xpdf = subs(diff ((f1-f),a),a,0)

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!