automaticdifferentiation
버전 1.0.0 (3.13 KB) 작성자:
David Codony
Computes the differentiation of a function handle with respect to specified variables at queried points
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));
인용 양식
David Codony (2026). automaticdifferentiation (https://kr.mathworks.com/matlabcentral/fileexchange/129229-automaticdifferentiation), MATLAB Central File Exchange. 검색 날짜: .
MATLAB 릴리스 호환 정보
개발 환경:
R2022b
R2021a 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux태그
| 버전 | 게시됨 | 릴리스 정보 | |
|---|---|---|---|
| 1.0.0 |
