Parsing mathematical expressions
Kontrast offers the function
kontrast.parseExpression which allows to parse and
not provide methods to deal natively with complex numbers, this
function can be used to perform calculations with complex numbers.
The syntax for the mathematical expressions is explained in this separate documentation article.
Interactive code example
The function is called as
options is an object with the following properties:
stringThe mathematical expression.
'real'This switch determines whether the calculation is using real numbers or complex numbers both internally and as a result type.
functionA function that actually performs the calculation. The function accepts a single object that contains the variable names as keys and numeric data as value.
arrayAn array of strings containing the names of all variables used in the expression.
HTMLElementA HTML element containing the render of the expression.