DifferentiableFunction model element

Function defines a differentiable real function of one variable, y = f(x), and provides root finding and integration capabilities for it.

(Notice that there is also a RealFunction element for non-differentiable functions.)

The element encapsulates access to Analysis routines in the Apache Common numerics library.

Usage

To add a differentiable function element to your model, drag the icon element to the list of your model elements and edit it to define the function and its derivative, and (optionally) change the root finding and integration methods.

The element implements the following basic methods:

All these methods print an error message and return a Double.NaN value if there was any error in the computation.

The element also implements the following methods for backwards compatibility, which call the corresponding methods above with a maximum number of evaluations equals to Integer.MAX_VALUE:

Besides this, the encapsulated Apache objects can be accessed using the methods:

Example of use

double y = function.value(0); // Evaluates the function at 0 
double root = function.solve(1000, 0,1); // Finds a root in the interval [0,1], allowing for a maximum of 1000 function evaluations 
double integral = function.integrate(1000,0,1); // Integrates in the interval [0,1], allowing for a maximum of 1000 function evaluations