Typescript Math Toolkit Function Parser


Back in the day, I wrote a C++ function parser for functions expressed in a calculator-style syntax (infix notation).  For example, a function of two independent variables s and t could be described as 2*s + 3*s^2 + sin(t).  After parsing, the function could be evaluated at specific values of s and t.

I thought it was an interesting experiment in string processing, something I do not do often as a (largely) numerical analyst.  Eventually, I needed the parser for a gig and it was converted to Actionscript and later to Javascript.

The function parser now has a home in the Typescript Math Toolkit as part of the function graphing engine, currently under development.


Prior implementations have been used in educational applications, but I believe the parser could also be used to provide graphical feedback on functions that have highly generic forms and whose specifics are derived from the application of heuristics and machine learning techniques.

Here is a screen shot of a demo I used to help validate the Javascript (ES5) version of the function graphing engine that uses the function parser to graph a user-input function.


While the JS version of the code base contained minimal unit tests, the TSMT employs a more robust set of specs.


If you would like to see the Typescript Math Toolkit make it into the open-source community much faster than the current pace, you can make your mark here.

Comments are closed.