Provided by: tcllib_1.15-dfsg-2_all

**NAME**

symdiff - Symbolic differentiation for Tcl

**SYNOPSIS**

package requireTcl8.5package requiregrammar::aycock1.0package requiremath::calculus::symdiff1.0math::calculus::symdiff::symdiffexpressionvariablemath::calculus::jacobianvariableDict_________________________________________________________________

**DESCRIPTION**

Themath::calculus::symdiffpackage provides a symbolic differentiation facility for Tcl math expressions. It is useful for providing derivatives to packages that either require the Jacobian of a set of functions or else are more efficient or stable when the Jacobian is provided.

**PROCEDURES**

Themath::calculus::symdiffpackage exports the two procedures:math::calculus::symdiff::symdiffexpressionvariableDifferentiates the givenexpressionwith respect to the specifiedvariable. (SeeExpressionsbelow for a discussion of the subset of Tcl math expressions that are acceptable tomath::calculus::symdiff.) The result is a Tcl expression that evaluates the derivative. Returns an error ifexpressionis not a well-formed expression or is not differentiable.math::calculus::jacobianvariableDictComputes the Jacobian of a system of equations. The system is given by the dictionaryvariableDict, whose keys are the names of variables in the system, and whose values are Tcl expressions giving the values of those variables. (SeeExpressionsbelow for a discussion of the subset of Tcl math expressions that are acceptable tomath::calculus::symdiff. The result is a list of lists: the i'th element of the j'th sublist is the partial derivative of the i'th variable with respect to the j'th variable. Returns an error if any of the expressions cannot be differentiated, or ifvariableDictis not a well-formed dictionary.

**EXPRESSIONS**

Themath::calculus::symdiffpackage accepts only a small subset of the expressions that are acceptable to Tcl commands such asexprorif. Specifically, the only constructs accepted are: · Floating-point constants such as5or3.14159e+00. · References to Tcl variable using $-substitution. The variable names must consist of alphanumerics and underscores: the${...}notation is not accepted. · Parentheses. · The+,-,*,/. and**operators. · Calls to the functionsacos,asin,atan,atan2,cos,cosh,exp,hypot,log,log10,pow,sin,sinh.sqrt,tan, andtanh. Command substitution, backslash substitution, and argument expansion are not accepted.

**EXAMPLES**

math::calculus::symdiff::symdiff {($a*$x+$b)*($c*$x+$d)} x ==> (($c * (($a * $x) + $b)) + ($a * (($c * $x) + $d))) math::calculus::symdiff::jacobian {x {$a * $x + $b * $y} y {$c * $x + $d * $y}} ==> {{$a} {$b}} {{$c} {$d}}

**BUGS,** **IDEAS,** **FEEDBACK**

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the categorymath::calculusof theTcllibSFTrackers[http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation.

**SEE** **ALSO**

math::calculus, math::interpolate

**COPYRIGHT**

Copyright (c) 2010 by Kevin B. Kenny <kennykb@acm.org> Redistribution permitted under the terms of the Open Publication License <http://www.opencontent.org/openpub/>