Computes the differentiation of a function handle with respect to specified variables at queried points
Vous suivez désormais cette soumission
- Les mises à jour seront visibles dans votre flux de contenu suivi
- Selon vos préférences en matière de communication il est possible que vous receviez des e-mails
automaticdifferentiation
Computes the differentiation of a function handle with respect to specified variables at provided points. It makes use of the built-in automatic differentiation (AD) framework of Matlab's Deep Learning Toolbox.
Calls
df = automaticdifferentiation(f,x,n);
df = automaticdifferentiation(f,x,nx,y,ny...);
df = automaticdifferentiation(...,ParallelFlag); % ParallelFlag = true/false
Inputs
f
Function handle. The number of inputs that f admits must match the number of provided Coordinates and Orders of differentiation. Must return a numeric array for each evaluation point.
x, y, ...
Coordinates of the points where derivatives are to be evaluated (numeric arrays of the same size).
nx,ny, ...
Order of differentiation for each variable (non-negative integer scalars).
ParallelFlag
Allow parallel for loops or not (scalar boolean). Optional input, the default is serial for loops.
Outputs:
df
Derivative of f with respect to specified variables, evaluated at the provided points. Numeric array with size equal to the concatenation of the sizes of theCoordinate inputs and the output of f, without singleton dimensions.
Note: The evaluation of the function f is not vectorized. Instead, a serial or parallel for loop is executed for each evaluation point. Therefore, f does not need to be defined using point-wise operators.
Examples
Scalar field in R2
x = 0:0.01:0.1;
y = 0:0.01:0.2;
[xx,yy] = meshgrid(x,y);
f = @(x,y) sin(2*pi*x.*y)+ y.^2; figure; surf(xx,yy,f(xx,yy));
dfdx = automaticdifferentiation(f,xx,1,yy,0); figure; surf(xx,yy,dfdx);
d2fdx2 = automaticdifferentiation(f,xx,2,yy,0); figure; surf(xx,yy,d2fdx2);
d2fdxdy = automaticdifferentiation(f,xx,1,yy,1); figure; surf(xx,yy,d2fdxdy);
Vectorial field in R1
g = @(x) [sin(2*pi.*x), x.*tan(2*pi.*x)]; figure; plot(x,g(x));
dgdx = automaticdifferentiation(g,x,1); figure; plot(x,dgdx(:,1),x,dgdx(:,2));
Citation pour cette source
David Codony (2026). automaticdifferentiation (https://fr.mathworks.com/matlabcentral/fileexchange/129229-automaticdifferentiation), MATLAB Central File Exchange. Extrait(e) le .
Informations générales
- Version 1.0.0 (3,13 ko)
Compatibilité avec les versions de MATLAB
- Compatible avec les versions R2021a et ultérieures
Plateformes compatibles
- Windows
- macOS
- Linux
| Version | Publié le | Notes de version | Action |
|---|---|---|---|
| 1.0.0 |
