Archive<< June 2019 >>
- TMS WEB Core v1.2 tips & tricks part 6: Exploring new TWebDBGrid features
- TMS WEB Core v1.2 tips & tricks part 5: Accessing microphone and camera
- Something I forgot to say about TMS XData 4.5 regarding URL endpoints
- TMS WEB Core v1.2 tips & tricks part 3 : Handling multiple forms with TApplication
- TMS XData 4.5: Parameter Binding and SwaggerUI
- TMS WEB Core v1.2 first tips and tricks : working with local files
- TMS WEB Core v1.2 Padua is released. Going to Ferrara now!
- TMS WEB Core v1.2 tips & tricks part 4: Display another form as a pop-up
- TMS WEB Core v1.2 tips & tricks part 2 : file access from Electron apps
- Adrian Gallero (20)
- Bart Holvoet (1)
- Bernard Roussely (1)
- Bruno Fierens (221)
- Gjalt Vanhauwaert (1)
- Holger Flick (11)
- Marcos Douglas B. Santos (5)
- Masiha Zemarai (11)
- Nancy Lescouhier (32)
- Pieter Scheldeman (14)
- Roman Yankovsky (1)
- Tunde Keller (3)
- Wagner R. Landgraf (61)
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