Symbolic derivatives

버전 1.1.0.0 (7.5 KB) 작성자: Jakub Rysanek
Computation of symbolic derivatives without the Symbolic Math Toolbox.
다운로드 수: 540
업데이트 날짜: 2016/10/5

라이선스 보기

Entire functionality is accessible via symbderiv() function.
Compatibility:
--------------
Only Matlab BASE is needed, additional toolboxes are not required.
The codes have been tested on M2010b, M2012b, M2016b, M2011A (Mac version)
Installation:
-------------
Main folder containing symbderiv() must be added to the Matlab search path.
Intended use:
--------------
symbderiv('x^2','x') computes the derivative of 'x^2' with respect
to a variable named 'x'. In this case the function returns the expected
result '2*x'. Computation of partial derivatives is straight-forward in that
all variables other than the selected variable are treated as constant.
Therefore, e.g. symbderiv('x*y*z','x') returns y*z.
The input function has to be a string, and the output derivative is also
returned as strings. Standard Matlab function eval() can then be used to
evaluate all computed derivatives numerically at given points.
The symbderiv() function is not suited for the computation of
Jacobians and Hessians directly. One can, however, make use of repeated
calls to symbderiv().

Example :
equations = {'exp(x^2)+y';'sin(x)'};% The system of 2 equations
varlist = {'x','y'}; % List of variables
jac = cell(2,2); % Container for Jacobian
for i = 1:length(equations)
jac(i,:) = symbderiv(equations{i},varlist); % Each Jacobian row as a gradient call
end

Example :
equation = '(x+y)^2';
symbderiv( symbderiv(equation,'x') ,'y') % dF/dxdy -> symbderiv() is simply called twice

Example :
equation = 'x^2';
analderiv = symbderiv(equation,'x');
x = 5; % -> we plan to evaluate the derivative at this point
numderiv = eval(analderiv);

User customization
------------------
The file func_list.m contains definitions of derivatives
for commonly used elementary functions, such as log(), sin(), etc.
This file can be freely expanded with other functions (potentially
user-defined) and their derivatives.

Note
----
The computed symbolic derivatives may look weird at first sight.
E.g. symbderiv('(x+y)^2','x') yields '((2)*(x+y)^(2-1)*(((1))))'
instead of '2*(x+y)'. Simplification rules on top of the computed
result are not applied in order not to slow down the computations.
The consequent numerical evaluation of the computed derivatives
using eval() tends to be rather fast in Matlab even if the underlying
expression contains many nested parentheses and redundant algebraic
operations.

인용 양식

Jakub Rysanek (2024). Symbolic derivatives (https://www.mathworks.com/matlabcentral/fileexchange/59438-symbolic-derivatives), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2016b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.1.0.0

...3.1415 constant in the derivative definition of normcdf() changed to "pi"

1.0.0.0

Initial code version

...