paceval. is the mathematical heart for your applications boosting product and service innovations, productivity and system safety.

USING paceval. – A SIMPLE CODE EXAMPLE

The example below walks you through the basic usage of paceval. so you can see how mathematical logic is defined, evaluated and scaled in real applications. While the example itself is intentionally simple, the same approach scales to complex mathematical models with hundreds of functions and variables. Multiple paceval.-Computation objects can be used side by side, allowing large models to be structured and evaluated efficiently. Individual expressions may range from compact formulas to very large mathematical definitions containing thousands or even millions of characters.

If you want to work with a math function like the one below

simple_example

then the function then looks like this in standard mathematical form

      f(x,y) = -sin(x*cos(x))^(1/y)

using two variables x and y.

You only need to create a paceval.-Computation object once with this code:

Programming with paceval. – C/C++

PACEVAL_HANDLE handle_pacevalComputation = paceval_CreateComputation(“-sin(x*cos(x))^(1/y)”, 2, “x y”, false);

(see also the paceval. Application programming interface (API))

The function paceval_CreateComputation(…) parses the specified mathematical expression, identifies all sub-functions and sub-calculations and transforms the formula into an optimized internal execution structure. The function returns a handle to this prepared computation object. This preparation step is performed once and typically takes less than one millisecond on standard IoT-class processors and even less on desktop systems.

Repeatedly interpreting a mathematical expression for different input values would quickly become inefficient, especially when evaluating thousands of data points, for example when plotting a function or processing large data sets. paceval. avoids this overhead by caching the prepared execution structure and reusing it for all subsequent evaluations. For best performance, static mathematical models should be prepared once at application startup using paceval_CreateComputation(…). Concrete results for specific variable values are then obtained efficiently by calling paceval_GetComputationResult(…).

For the example above, if you want to get the result for x = 0.5 and y = 2, just use this code:

Programming with paceval. – C/C++

long double valuesVariablesArray[2];
long double ldResult;

valuesVariablesArray[0] = 0.5; //the x-value
valuesVariablesArray[1] = 2; //the y-value

ldResult = paceval_ldGetComputationResult(handle_pacevalComputation, valuesVariablesArray, NULL, NULL);

//ldResult is approximately -0.65180178245228

(see also the paceval. Application programming interface (API))

The return value represents the numerical result of the computation. The function paceval_GetComputationResult(…) evaluates the prepared execution structure created by paceval_CreateComputation(…) and reuses all cached sub-functions and sub-calculations. Because the mathematical expression has already been parsed and optimized, the runtime performance of each evaluation is comparable to compiled standard C++ code and in some cases even faster, depending on the structure of the function.

For comparison, the following section shows the equivalent implementation using standard C++ source code: 

Standard programming – C/C++

long double valuesVariablesArray[2];
long double ldResult;

valuesVariablesArray[0] = 0.5; //the x-value
valuesVariablesArray[1] = 2; //the y-value

ldResult = -1*powl(sinl(valuesVariablesArray[0]*cosl(valuesVariablesArray[0])), 1/valuesVariablesArray[1]);

//ldResult is approximately -0.65180178245228

A key advantage of paceval. compared to standard C++ implementations is improved readability and built-in error handling. In the example above, setting the variable y to zero or close to zero would cause the standard C++ implementation to fail due to a division by zero, without clearly indicating the source of the error.

paceval. automatically detects such numerical issues and provides precise information about their location and cause.

Detailed error handling can be implemented using paceval_GetIsError(…) and paceval_GetErrorInformation(…), as described in the paceval. Application programming interface (API) documentation. Beyond error handling, paceval. significantly improves the maintainability of complex mathematical models. Mathematical expressions can be stored centrally as readable strings, for example in configuration files or databases, instead of being scattered across application code. Since paceval. imposes no practical limits on the length of expressions or the number of variables, even very large models remain manageable. Models consisting of dozens of highly complex functions with many variables, such as those found in sensor-rich automotive systems, safety monitoring applications or financial analytics and trading platforms, can be implemented and maintained in a transparent and understandable way. For highly complex models, numerical robustness becomes increasingly important. Long expressions and deep computation chains often introduce rounding errors that are difficult to track using standard floating-point arithmetic. paceval. addresses this challenge through Trusted Interval Computation (TINC), an optimized form of interval arithmetic designed for high performance. When TINC is enabled, paceval.  computes a numerical interval that reliably bounds the true result of the calculation. 

In the example above, enabling TINC requires only the small code changes highlighted in green. The returned interval explicitly shows the range in which the correct result lies, providing additional confidence and transparency for complex computations:

Programming with paceval. – C/C++

PACEVAL_HANDLE handle_pacevalComputation = paceval_CreateComputation(“-sin(x*cos(x))^(1/y)”, 2, “x y”, true);

(see also the paceval. Application programming interface (API))

Programming with paceval. – C/C++

long double valuesVariablesArray[2];
long double ldResult;

long double minResultInterval;
long double maxResultInterval;

valuesVariablesArray[0] = 0.5; //the x-value
valuesVariablesArray[1] = 2; //the y-value

ldResult = paceval_ldGetComputationResult(handle_pacevalComputation, valuesVariablesArray, &minResultInterval, &maxResultInterval);

// ldResult is approximately -0.65180178245228
// minResultInterval as lower confidence bound is  -0.6518017824522809982
// maxResultInterval as upper confidence bound is -0.6518017824522740538

(see also the paceval. Application programming interface (API))

With paceval., approximations can be generated and evaluated quickly and reliably

Using a simple script, a mathematical approximation can be generated from large measurement series within seconds, even if the resulting function is very long and complex. This approximation represents a precise mathematical model that can be reused and evaluated consistently across different programs. By relying on a single, well-defined model instead of multiple ad-hoc implementations, inaccurate and error-prone calculations are avoided and valuable development time is freed for further iteration and improvement.

In engineering mathematics, complex products are often characterized by extensive measurement series. To use these measurements in software systems, a mathematical model must be derived through approximation. As the number of measurement points increases, these approximations quickly become very long and complex. In many cases, it is no longer possible to express the behavior of the system using a simple analytical function, especially in critical regions where small numerical deviations can lead to incorrect or even physically invalid results.

A typical example is a turbine system. Its behavior depends on operating time, size, manufacturing tolerances and material properties. Even small variations during production lead to individual characteristics that require turbine-specific adjustments. As illustrated in the figure, approximations based on a small number of measurements often remain imprecise in critical areas, particularly near zero crossings. Reliable engineering software therefore requires approximation models that can scale to thousands or tens of thousands of measurement points while maintaining precision exactly where it matters most. paceval. enables such large and highly specific approximation models to be handled, evaluated and reused efficiently, making precise and customized models readily available for real-world engineering applications.

A simple example: Suppose you want to approximate the measurement points (1.5, 6), (2.5, 3) and (3.5, 25), where the values are directly related and form a piecewise-defined behavior. As illustrated in the figure, this behavior can be expressed as a single mathematical function using conditional expressions. The resulting formula can be passed to paceval. directly, without additional preprocessing.

paceval. evaluates such functions efficiently and in parallel, enabling fast and deterministic execution even for more complex approximations.
The same approach applies to other approximation strategies, including trigonometric, polynomial or hybrid models, depending on what best fits the underlying data.

Further calculation examples with paceval.

As illustrated, paceval. makes complex logical structures directly executable as explicit mathematical expressions. Conditional logic, such as decision trees with costs per decision, can be represented in a readable and transparent form and evaluated efficiently at scale. Thanks to its optimized execution model, paceval. handles large expressions with many variables, deep branching logic and repeated evaluations without practical limits on expression length or model complexity. Typical applications include decision trees with cost functions, matrix computations with variable inputs and other data-driven models where clarity, performance and scalability are equally important.

As an example, consider the decision tree shown on the left, with branching conditions based on the variables a and b.
Instead of implementing each decision path explicitly in code, the entire tree can be represented as a single mathematical function using conditional expressions. This function can be passed directly to paceval., which evaluates it efficiently based on the current values of a and b.
Internally, the execution is automatically parallelized, allowing fast and deterministic evaluation even for complex decision logic.

The same approach scales naturally as the number of branches and variables increases. In systems with many inputs, such as sensor-based applications, the number of possible decision paths grows exponentially. For example, 20 sensors with two possible decisions each already result in more than one million possible paths. Implementing such logic explicitly would lead to extremely large, hard-to-maintain programs that are highly sensitive to changes in costs, sensor configurations or decision criteria. By expressing the decision logic as a mathematical model, paceval. enables this complexity to be handled compactly, transparently and reliably, reducing large decision trees to a concise and maintainable representation.

When multiplying two matrices with paceval., each matrix entry is represented by a separate computation object. In the example shown, this results in nine independent computation objects, one for each entry of the resulting matrix, each defined as an explicit mathematical expression. These computation objects are then evaluated using the variable values x, y, z, u, v and w. Since each entry is computed independently, paceval. can evaluate them efficiently and in parallel.

This approach scales naturally to larger matrices. paceval. imposes no practical limit on the number of computation objects, allowing even large matrix operations to be expressed, evaluated and maintained in a clear and structured way.

The examples shown above illustrate only a small subset of what can be expressed and executed with paceval. In general, any computational problem that can be formulated as explicit mathematical expressions can be evaluated efficiently and deterministically. Typical applications include weighted and directed graphs, systems of differential equations, scalar products, geometric transformations, matrix and vector operations, spectral transformations such as DCT and FFT, numerical optimization methods including Newton’s method, eigenvalue and singular value decomposition, polynomials, cyclic redundancy checks and cryptographic primitives such as zero-knowledge proofs.

paceval. is also well suited for selected artificial intelligence workloads. Neural networks, hidden Markov models for gesture recognition and similar models can be converted into closed-form mathematical expressions. This makes their behavior transparent, reproducible and executable on standard CPU-based systems without relying on specialized hardware. Further examples and background on the conversion of AI models into mathematical expressions can be found in the paceval and artificial intelligence repository on GitHub.

 

Copyright © paceval.® All rights reserved.