How to implement “built-in” numerical integration?

Hi, I have a question about Numerical integration.
I want to implement numerical integration (e.g. via RectIntegrator) directly in expressions, for example:

S=numintRECT{x}(sin(x)*e^(x^2/8) 0 1 1000)*D+2.5

In theory, numintRect should be a function that returns a defined integral via integrator.Integral(). But how to implement it? The documentation provides an example for direct use in the code, but is it possible to do this as a Function or Expression? Which class is better to inherit from to have access to the integral function and the variable “x” as text parameters?

Hi, Vitalii.

In the latest version 3.7 of the library new class TExternalFunctionFormula introduced. This class together with the TFunction class allows to realize the functionality of specific (external) evaluation algorithms.

Numeric integration functions (1D and 2D) have been realized in the library using this mechanism (IntRECT, IntSIMPSON, IntGAUSS2, IntGAUSS3, IntBRICK, IntGAUSS4, IntGAUSS9).
They work as other functions and can be used in math expressions

See Analytix.Numerics.Functions.Integration file. You can use them as the examples of external functions realization to implement your own functionality.

1 Like