Archive<< April 2019 >>
- Video: Creating a database-driven, interactive Google Maps web application with Delphi Rio
- Video: Developing a Database-driven Web Application with Delphi Rio and TMS Web Core
- New features in TMS Analytics & Physics 2.8
- TMS FNC Cloud Pack BETA
- TMS WEB Core v1.2 Padua beta is here for TMS ALL-ACCESSS users
- Access the camera with TMS WEB Core 1.2 Padua
- Adrian Gallero (20)
- Bernard Roussely (1)
- Bruno Fierens (215)
- Gjalt Vanhauwaert (1)
- Holger Flick (2)
- Marcos Douglas B. Santos (5)
- Masiha Zemarai (9)
- Nancy Lescouhier (32)
- Pieter Scheldeman (13)
- Roman Yankovsky (1)
- Tunde Keller (3)
- Wagner R. Landgraf (59)
Most Recent Post | Index List
Monday, January 07, 2019TMS Analytics & Physics developing library contains many algorithms for manipulating with symbolic math expressions. For example, it is able to evaluate symbolic derivatives of complicated expressions, approximate functions with symbolic, user-defined basis and so on. The result of any such manipulation is another symbolic expression. Many efforts in last versions has been spent for simplifying result expressions. The expression simplification required for presenting the result in shorted and readable form. For example, the derivative of y^(x+1) by x can be formally written as (x+1)*y^(x+1-1) and this is correct answer, but after simplification it would be simpler for reading (x+1)*y^x.
Nevertheless, all symbolic algorithms manipulate with math expressions, presented as plain Unicode strings. The main reason for this is providing simple interface for using math formulae inside Delphi programs. Presenting math expressions as plain strings requires using special syntax for different math structures. For example, power expression written with power operator x^y, vector expression written with brackets [x y z] and so on. Such syntax is not natural for math formula notation and so, result expressions are not suitable for human reading.
New version 2.7 of TMS Analytics and Physics pack contains new tools to convert symbolic expressions, generated with the library, to TeX format (https://en.wikibooks.org/wiki/LaTeX/Mathematics). This format is widely used for creating scientific articles and documents. There are many free tools for drawing math formula, presented in TeX format in desktop and Web applications, converting documents to PDF or DOC format and so on.
Let us consider as symbolic expressions, generated with the library, can be drawn with Web browser as math formulae. First, we need to convert the expression to the TeX format. Here is an example of code for converting expressions:
In the code above an instance of the TAnalyticsTeXConverter class created. This class has the Convert method for converting symbolic expressions to the TeX format. For the expression, result string in TeX format is the following:
var f, texf: string; converter: TAnalyticsConverter; begin f:= 'A*sin(n*x)+B/2*e^(m*y)'; converter:= TAnalyticsTeXConverter.Create; try texf:= converter.Convert(f); except on E: Exception do // Show exception message... end; // Using formula in TeX format... end;
Expression in TeX format can be then drawn in Web browser using, for example, MathJax CDN service (https://en.wikipedia.org/wiki/MathJax). For doing this we can generate a file with the following HTML code:
where XXX must be replaced with the TeX formula. Launching browser for the generated HTML file the formula will be drawn. For the formula above, we get:
The converter to TeX format supports all formulae, satisfying the syntax of the library. All types of expressions can be converted and rendered, including implicit derivative operators, special functions and operators (sum, square root and so on).
There are some other examples of complicated formula, rendered in Web browser with the described approach.
- Implicit derivative expression:
- Expression with indexed data:
- Matrix/vector expression:
- Special function/operator expression:
As can be seen from the pictures above, all rendered formulae presented in natural math format and are easy to read and understand. Thus, all symbolic results, evaluated with the library, can be shown to the user as math formulae.
The version 2.7 is already available. Source code of the example application can be downloaded from here.
This blog post has received 6 comments.
Most Recent Post | Index List