Function: DYDX
Purpose: Determine derivative of a mathematical expression.
Category: MATH
File: dydx.src
Author: J.P. Terlouw
Use: INTEGER DYDX( INEXPR, Input character
VARIABLE, Input character
OUTEXPR, Output character
DERIVATIVE, Output character
CONSTANTS, Output character array
MAXCONST, Input integer
NUMCONST ) Output integer
DYDX status return code:
0 success
-1 syntax error
-2 syntax error
-3 unknown function
-4 function too large for output argument
-5 derivative too large for output argument
-6 constant name too long for output argument
-7 too many constants for output argument
INEXPR expression to be differentiated.
VARIABLE variable with respect to which will be differentiated.
OUTEXPR DYDX's interpretation of INEXPR.
DERIVATIVE derivative of INEXPR with respect to VARIABLE.
CONSTANTS names of constants appearing in INEXPR (in any order).
MAXCONST number of elements of CONSTANTS.
NUMCONST number of constants found.
Description: DYDX determines the derivative of the expression given
in the first argument using symbolic differentiation.
All expressions involved (should) follow the same syntax as
described in fie.dc2.
DYDX recognizes all functions supported by FIE, except functions
with a variable number of arguments.
Function names are case-insensitive; variables and constants
are case-sensitive.
Functions which are not strictly differentiable, such as abs,
sign and rect, produce a practical 'derivative'. E.g. abs(x)
results in sign(x), and rect(x) results in 0.
Other non-differentiable functions produce 'BLANK'.
Constants can be enclosed in braces ( { } ). After DYDX has
removed the braces, they are treated in the same way as other
constants, with the exception that braced constants do not
appear in the output argument CONSTANTS. This is a way to
separate fixed symbolic constants and free parameters.
Note that in this case the input expression is not compatible
with FIE. The output expressions are compatible, however.
Example: INTEGER DYDX
CHARACTER*80 OUT, DERIV
CHARACTER*10 C(5)
ICODE = DYDX('sin(a*x)**b', 'x', OUT, DERIV, C, 5, NC)
Upon return ICODE will be zero, OUT will contain the string
'SIN((a*x))**b', DERIV '((a*COS((a*x)))*(b*SIN((a*x))**(b-1)))',
NC will be 2 and the first 2 elements of C will contain
'b' and 'a'.
Updates: Feb 3, 1997: JPT document created.
Jun 15, 1998: JPT added functions abs and sign.
Jul 1, 1998: JPT added Bessel functions bj, by, bi, bk.
Aug 26, 1998: JPT added functions recently introduced in fie.
Dec 22, 1998: JPT added 3- and 4-arg. non-differentiable fnctns.
Feb 16, 1999: JPT fixed bug in Fun4