
MathMatize Math Engine
MathMatize math engine overview
MathMatize Math Engine
MathMatize facilitates the creation of randomized exercises that accept free-form symbolic math responses. The randomization and processing of math expressions is supported behind the scenes by a fast and reliable math engine. Math expressions are first validated and interpreted using a custom math parser, and then simplified using a math library. MathMatize integrates a virtual keyboard making it easy for users, both content creators and students, to input math expressions. The keyboard gives access to the most commonly used math symbols, operators and functions with a few simple clicks.
Conventions and assumptions
Mathematical expressions can sometimes be ambiguous, e.g. does the expression xy mean the product of two variables x and y?
Or does it reference a single variable named xy? Different notational conventions may be adopted to make the meaning of mathematical expressions precise.
Moreover, the ambiguity in an expression may be resolved by the context in which the expression is used.
Here, we highlight the conventions utilized by MathMatize.
xyis interpreted as an implicit multiplication between variablesxandy. Multi-letter variable names can be entered by typing the name in text mode. Text mode is entered and exited by typing a quotation mark", e.g. to enter the variable namexyzthe user would type"xyz"(with the quotation marks explicitly typed). The multi-letter variable name is not italicized and printed in upright font to visually distinguish it from implicitly multiplied single letter variables.- The exponent operator (
^) has a higher precedence than the unary minus operator. Therefore,-1^2is interpreted as-(1^2). It is recommended that parenthesis be used whenever there is chance of ambiguity. - Implicit multiplication to a variable has higher precedence than function evaluation.
Therefore,
sin 2xyis interpreted assin(2xy). But,sin x + yis interpreted assin(x) + y. Again, it is recommended that parenthesis be employed to avoid ambiguity. - The raw LaTeX of all MathMatize functions, custom functions and some constants needs to be properly escaped. Fortunately, users can input expressions without the need to explicitly escape names as this is handled automatically by macros triggered in the input field as they type. When properly escaped the name is printed in an upright serif font. However, when copying and pasting text (and sometimes when an expression is edited after initial input) the macro can fail to trigger. In this case, the name will be rendered in an italic sans serif font, e.g. "sin". MathMatize will warn the user to retype the unescaped name otherwise it will be interpreted as an implicitly multiplied product, i.e. "s * i * n".
- In general, the math engine assumes that the input math expressions are to be evaluated over the reals (ℝ),
e.g.
(-1)^(1/3)is evaluated as equal to-1,the real root, and not1/2 + \sqrt{i}/2, the principal root. Therefore, attempting to evaluate(-1)^(1/2)orln(-1)will yieldNaN(Not a Number). However, professors can evaluate the expressions above over the complex plane (ℂ) by forcing a complex context.
See also: