Blog Options
Archive
<< March 2026 >>-
Monday 23
- Simplify Mapping Across Platforms with TMS FNC Maps -
Wednesday 18
- The Next Evolution of Charting in Delphi: Look & Feel -
Monday 16
- Better Delphi Code from AI Agents with TMS Skills -
Friday 13
- TMS Training Days 2026 - Community Evening -
Wednesday 11
- The Next Evolution of Charting in Delphi: Data Import & Export -
Monday 9
- Meet Gjalt Vanhouwaert at TMS Training Days 2026 -
Friday 6
- Meet Pieter Scheldeman at TMS Training Days 2026 -
Thursday 5
- Enabling TLS 1.3 in TMS MQTT and TMS FNC Products -
Wednesday 4
- Meet Antonio Zapater at TMS Training Days 2026 -
Tuesday 3
- The Next Evolution of Charting in Delphi: Getting Started -
Monday 2
- Meet José Leon Serna at TMS Training Days 2026
- Meet Dennis Roehner at TMS Training Days 2026
- Meet Bradley Velghe at TMS Training Days 2026
- Unlock PDF Interactivity in Delphi with TTMSFNCPDFLib Form Fields
Authors
- Bernard Roussely (3)
- Wagner Landgraf (98)
- Dennis Röhner (1)
- Roman Yankovsky (2)
- Bart Holvoet (42)
- Aaron Decramer (82)
- Pieter Scheldeman (134)
- Nancy Lescouhier (32)
- Adrian Gallero (34)
- Bruno Fierens (450)
- Marcos Douglas B. Santos (5)
- Bernard (4)
- Bradley Velghe (36)
- Andrew Simard (86)
- Holger Flick (15)
- Gjalt Vanhouwaert (44)
- Tunde Keller (37)
- Masiha Zemarai (117)
Blog
All Blog Posts | Next Post | Previous Post
Introducing functional derivatives is easy
Monday, March 20, 2017
The unique feature of Analytics library is symbolic derivatives calculation. The library provides the simplest way to get a symbolic derivative expression for almost any complicated expression. There are predefined derivative for all standard functions: trigonometric, hyperbolic, logarithmic and exponential, inverse trigonometric and hyperbolic, and other.Another fine thing is that any developer can easily define derivative for any other function. Let us consider how to define derivative for special Gamma function (https://en.wikipedia.org/wiki/Gamma_function#General). Its derivative is defined via another special function Digamma (Polygamma function of order 0, https://en.wikipedia.org/wiki/Polygamma_function). Hereafter the Gamma function denoted as G and the Digamma (and Polygamma) as Y. Then, the derivative formula is: d(G(x))/dx = G(x)*Y(x).
To introduce new functional derivative new class must be implemented. In our case, the class is inherited from TSimpleFunctionalDerivative because the function has one argument only. Here is the code of the realized class:
TGammaDerivative = class sealed(TSimpleFunctionalDerivative)
protected
function GetFunctionName(): string; override;
function BaseDerivative(argument: TBaseExpression): TBaseExpression; override;
public
class function IsRealized: boolean; override;
end;
function TGammaDerivative.GetFunctionName: string;
begin
result:= 'G';
end;
class function TGammaDerivative.IsRealized: boolean;
begin
result:= true;
end;
function TGammaDerivative.BaseDerivative(argument: TBaseExpression): TBaseExpression;
var
ge: TBaseExpression;
dge: TBaseExpression;
begin
ge:= TFunctionExpression.CreateSimple('G', argument);
dge:= TFunctionExpression.CreateSimple('Y', argument);
result:= TProductExpression.MakeProduct(ge, dge);
end;
Now we can calculate derivatives for expressions with the Gamma function. For the simplest case with input string G(x) we get the expected output string G(x)*Y(x). No surprise here, because we just wrote the code, which produces the output.
But the amazing thing is when we trying to calculate the derivative expression for the Gamma function with a composite argument. As example, for the input string G(x^2+1) it produces the output string (G(x^2+1)*Y(x^2+1))*(2*x) which is totally correct for this case. And the output is correct for all the expressions with the Gamma function. It is because the Analytics library cares about other things, like implementing the chain rule for derivation process.
The source code of the example project is available here.
Nancy Lescouhier
This blog post has not received any comments yet.
All Blog Posts | Next Post | Previous Post