# Existing Tools for Math Expression Equivalence Logic

Note - this question was posted here and garnered some decent replies before it was closed as off-topic in Stack Overflow.

Online systems, such as ALEKS, Cengage's WebAssign, and even Khan Academy employ some kind of logical matching for polynomial expressions and numerical values (ie, fractions). What unpaid tools (libraries, command line programs, scripts, etc) exist that can provide expression/numerical matching? For example, a student enters the expression

$$2p^2(p+5)-8,$$

but the following expression is equivalent and would also be acceptable:

$$2(p^2+4p-4)(p+1).$$

The question about how to do this mathematically has an excellent answer in this post, and a question addressing one particular way to implement this has a partial answer in this post. Sympy looks promising, but the command line Maxima could work, and so could the WolframAlpha API, Maple, MatLab, and any number of symbolic computer algebra systems.

It's fine to talk about things that "could work", but what tools are already being used? How has this already been implemented? Can anyone speak from experience about what online math learning programs are using on the backend? Give examples or direct to existing projects.

To clarify the question, I'm talking about logically comparing simple expressions(middle/high school math), minimally complicated, with canonical forms typically easy to obtain. The implementation will be online (html+nifty_tool) and input will most likely be captured as a string unless someone can suggest a better input method for math learners - a LaTeX front-end perhaps?

• Look at WeBWorK which uses a pearl-based language. webwork.maa.org Commented Aug 4, 2018 at 0:42
• This tool (wiris.com/en/mathtype) builds in Microsoft's MathType tool, including handwriting recognition, to online services such as Gsuites, Moodle, Schoology, Canvas, etc. Very basic use is free for schools, subscription otherwise. Commented Sep 23, 2018 at 1:53
• EquatIO (by TextHelp, the next generation of the dead g(math) addon) is free for teachers (with premium plan costs) and has an intuitive typed, handwritten, voice dictated, screen shot reader, and Desmos-based graph inputs. The outputs are either URL to an image (likely mathjax based or similar for the LaTeX, the link is to their own API), plain text (ie, coding format) and LaTeX code formats. This might be my favorite I've found, especially considering the multiple in/out formats and integration with Google and Microsoft products. Commented Sep 26, 2018 at 22:23
• While there is often a lot of disdain here for simplifying solutions, if you have some standard for the required format of an answer, it actually takes care of this problem. This is true whether you do it manually, require the student to do it manually, or have a CAS system perform the operations. Once the anwser is in prescribed simplified form, than you just see if the answer is exactly the same as the key. Commented Sep 27, 2018 at 3:07
• @guest This is what stack.ed.ac.uk does - the program teaches students to write correctly formatted math (programming style, not in TeX) and shows them the TeX formatted results. Commented Sep 27, 2018 at 18:50

## 1 Answer

Almost 20 years ago, I faced a similar issue in the course of designing some on-line calculus exercises... For me, it turned out to be simplest to use a Monte-Carlo idea, namely, to evaluate both expressions at a "random" set of locations, and test for agreement within some not-too-tight bound. Yes, some necessity of tolerating invalid inputs and such, but such "errors" can be "caught" and dealt with.

Getting the details reasonably correct was much easier than implementing a genuine symbol-manipulation version... which would inevitably have some open-ended issues.

(In particular, this was implemented in Java, and "expressions" were converted to tree structures, and so on. Pretty typical.)

• This is a useful comment. Since the details of implementing symbolic systems tend to be... diverse, I'm also looking for existing tools that have been developed to overcome these issues. Did you see the response about STACK in the original post? Commented Aug 4, 2018 at 0:39
• Probabilistic equality testing algorithms have been used for many decades in computer algebra systems, Search on the Schwartz–Zippel lemma for an entry point into the literature. Commented Sep 29, 2018 at 2:39