Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

Formula Processing: f(x), df/dx
[Symbolic Analysis]

Collaboration diagram for Formula Processing: f(x), df/dx:

This module contains all functions for evaluation of and symbolic operations on formulae represented as libSBML Abstract Syntax Trees (AST). More...


Modules

 AST Manipulations
 Diverse Functions to manipulate libSBML Abstract Syntax Trees.

Functions

SBML_ODESOLVER_API void setUserDefinedFunction (double(*udf)(char *, int, double *))
 Sets function pointer for user defined function to udf.
ASTNode_t * copyAST (const ASTNode_t *f)
 Copies the passed AST, including potential SOSlib ASTNodeIndex, and returns the copy.
SBML_ODESOLVER_API double evaluateAST (ASTNode_t *n, cvodeData_t *data)
 Evaluates the passed formula n by a simple recursion and returns the result as a double value.
SBML_ODESOLVER_API ASTNode_t * differentiateAST (ASTNode_t *f, char *x)
 Returns the derivative f' of the passed formula f with respect to the passed variable x, using basic differentiation rules.
ASTNode_t * determinantNAST (ASTNode_t ***A, int N)
 !! experimental function determinantNAST !! NOT TESTED !! !! WILL RUN OUT OF MEMORY FOR BIG SYSTEMS !! calculates the determinant of the jacobian matrix, is not used and can only be activated with hidden commandline option -d.

Detailed Description

This module contains all functions for evaluation of and symbolic operations on formulae represented as libSBML Abstract Syntax Trees (AST).

These functions are used both for numerical and symbolic analysis


Function Documentation

SBML_ODESOLVER_API void setUserDefinedFunction double(*)(char *, int, double *)  udf  ) 
 

Sets function pointer for user defined function to udf.

Takes a function pointer as an argument. This function udf is called in evaluateAST to interface external data that can be supplied by a calling applications. It must return a double value for the current time of an integration run.

ARGUMENTS TO THE PASSED FUNCTION:

char *: must be the name of a function used in any formula in the SBML file, but not defined via an SBML Function Definition in the same SBML model

int: is the number of arguments the SBML function takes, which is also the size of the following double array

double *: is an array that is filled by evaluateAST to supply the external function with current values of the arguments of the respective function the SBML model

POSSIBLE APPLICATIONS:

Setting a set of udfs could later also be used to enhance integration performance by using SBML sboTerms in kinetic laws, i.e. for hard-coded kinetic law evaluation!

The function might also be useful for introducing stochastic effects to the ODE system. An external function could call a random number generator.

Sorry, if above description is confusing, because of two different types of `function'. Basically, it allows a hard-coded definition of an otherwise undefined function in the SBML file. While this would be invalid SBML (!), it allows a model to access external data. We will in one of the next releases provide an example of a simple interpolation function, that takes only the current time as argument and interpolates a value for the current time from an external time series data set.

ASTNode_t* copyAST const ASTNode_t *  f  ) 
 

Copies the passed AST, including potential SOSlib ASTNodeIndex, and returns the copy.

SBML_ODESOLVER_API double evaluateAST ASTNode_t *  n,
cvodeData_t data
 

Evaluates the passed formula n by a simple recursion and returns the result as a double value.

Variable names are searched in passed cvodeData, which is an SBML_odeSolver specific data structure, containing current values of indexed AST. See files cvodedata.c/h and odeConstruct.c to learn how this structure is built.

Not implemented:

  • Complex numbers and/or checking for domains of trigonometric and root functions.
  • Checking for precision and rounding errors.
  • SBML model specific function DELAY
  • SBML Function Definitions
  • LAMBDA (only used in SBML Function Definitions)

The node type AST_DELAY defaults to 0. The SBML DELAY function and unknown functions (SBML user-defined functions) use the value of the left child (first argument to function) or 0 if the node has no children and produce an errorMessage via SOSlibs Error Management System.

VARIABLES:

find the value of the variable in the data->value array. SOSlib's extension to libSBML's AST allows to add the index of the variable in this array to AST_NAME (ASTIndexName). If the ASTNode is not indexed, its array index is searched via the data->model->names array, which corresponds to the data->value array. For nodes with name `Time' or `time' the data->currenttime is returned. If no value is found a fatal error is produced.

exp(1) is used to adjust exponentiale to machine precision

pi = 4 * atan 1 is used to adjust Pi to machine precision

FUNCTIONS:

Evaluate external functions, if it was set with setUserDefinedFunction

arccot x = arctan (1 / x)

arccoth x = 1/2 * ln((x+1)/(x-1))

arccsc(x) = Arctan(1 / sqrt((x - 1)(x + 1)))

arccsch(x) = ln((1 + sqrt(1 + x^2)) / x)

arcsec(x) = arctan(sqrt((x - 1)(x + 1)))

arcsech(x) = ln((1 + sqrt(1 - x^2)) / x)

cot x = 1 / tan x

coth x = cosh x / sinh x

csc x = 1 / sin x

csch x = 1 / sinh x

log(x,y) = log10(y)/log10(x) (where x is the base)

sec x = 1 / cos x

sech x = 1 / cosh x

SBML_ODESOLVER_API ASTNode_t* differentiateAST ASTNode_t *  f,
char *  x
 

Returns the derivative f' of the passed formula f with respect to the passed variable x, using basic differentiation rules.

VARIABLES

check if variable x is part of f(x): if not f' = 0

f(x) = x => f' = 1

OPERATORS

f(x)=a(x)+b(x) => f'(x) = a' + b'

f(x)=a(x)-b(x) => f'(x) = a' - b'

catch n-ary operators with operand number != 2, and decompose in simplifyAST

f(x)=a(x)*b(x) => f'(x) = a'*b + a*b'

f(x)=a(x)/b(x) => f'(x) = a'/b - a/b^2*b'

f(x)=a(x)^b => f'(x) = b * a^(b-1)*a'

f(x)=a^b(x) => f'(x) = f * ln(a)*b'

f(x)=a(x)^b(x) => f'(x)= f * ( b/a*a' + ln(a)*b' )

FUNCTIONS:

f(x)=abs(a(x)) => f' = sig(a)*a' WRONG: CAN RESULT IN A DISCONTINUOUS FUNCTION!

TRIGONOMETRIC FUNCTION DERIVATIVES mostly taken from http://www.rism.com/Trig/circular.htm and http://www.rism.com/Trig/hyperbol.htm

f(x)=arccos(a(x)) => f' = - a' / sqrt(1 - a^2)

f(x)=arccosh(a(x)) => f' = a' / sqrt(a^2 - 1)

f(x)=arccot(a(x)) => f' = - a' / (1 + a^2)

f(x)=arccoth(a(x)) => f' = - a' / (-1 + a^2)

f(x)=arccsc(a(x)) => f' = - a' * a * sqrt(a^2 - 1)

f(x)=arccos(a(x)) => f' = - a' * a * sqrt(a^2 + 1)

f(x)=arcsec(a(x)) => f' = a' * a * sqrt(a^2 - 1)

f(x)=arcsech(a(x)) => f' = - a' * a * sqrt(1 - a^2)

f(x)=arcsin(a(x)) => f' = a' / sqrt(1 - a^2)

f(x)=arcsinh(a(x)) => f' = a' / sqrt(1 + a^2)

f(x)=atan(a(x)) => f' = a' / (1 + a^2)

f(x)=atan(a(x)) => f' = a' / (1 - a^2)

f(x) = ceil(a(x))

f(x)=cos(a(x)) => f' = a' * -sin(a)

f(x)=cosh(a(x)) => f' = a' * -sinh(a)

f(x)=cot(a(x)) => f' = - a' / (sin(a))^2

f(x)=cot(a(x)) => f' = - a' / (sinh(a))^2

f(x)=csc(a(x)) => f' = - a' * csc(a) * cot(a)

f(x)=csch(a(x)) => f' = - a' * csch(a) * coth(a)

f(x)=e^a(x) => f' = e^a * a'

f(x) = floor(a(x)) WRONG: CAN RESULT IN A DISCONTINUOUS FUNCTION!

f(x)=ln(a(x)) => f' = 1 / a * a'

f(x)=log(b,x) = 1/ln(b)*ln(x) differentiate ln(x)!

f(x)=root(a(x),b(x)) = a(x)^(1/b(x)) differentiate this!

f(x)=sec(a(x)) => f' = a' * sec(a) * tan(x)

f(x)=sech(a(x)) f' = - a' * sech(a) * tanh(a)

f(x)=sin(a(x)) => f' = a' * cos(a)

f(x)=sinh(a(x)) => f' = a' * cosh(a)

f(x)= tan(a(x)) => f' = a' / (cos(a))^2

f(x)= tanh(a(x)) => f' = a' / (cosh(a))^2

ASTNode_t* determinantNAST ASTNode_t ***  A,
int  N
 

!! experimental function determinantNAST !! NOT TESTED !! !! WILL RUN OUT OF MEMORY FOR BIG SYSTEMS !! calculates the determinant of the jacobian matrix, is not used and can only be activated with hidden commandline option -d.

Doesn't work if expressions get too big for yet unknown reasons!??


Generated on Wed Dec 21 18:10:38 2005 for SBML ODE Solver Library API by  doxygen 1.4.4