# Do any tools exist that convert "pretty print" equations into "inline text" equations?

Context: I am an assistant professor of mathematics at a small school in the US.

Many of my courses have homework assignments administered by WeBWorK. A small minority of students struggle mightily (mostly with parenthesis) when assembling inline text expressions like $$\texttt{[(e^(3x^2-7)(6x))(5x+2)-(e^(3x^2-7))(5)][(5x+2)^2]}$$ in order to represent mathematical expressions like $$\frac{(e^{3x^2-7}(6x))(5x+2)-(e^{3x^2-7})(5)}{(5x+2)^2}.$$ This brings me to my question: Are there any online tools that could allow a student to assemble something in "pretty print" and then decompose the given expression into inline text? Wolfram Alpha and LaTeX both go the wrong way--they transform inline text into beautiful expressions.

Note: I believe that the students learn something significant from learning how to carefully type these inline expressions, but for those who really struggle, I don't want that to be what prevents them from completing an assignment.

• I think it would not be hard to get mathquill.com to do what you want. It is the open source engine behind how Desmos does math expression parsing. Students find it to be intuitive. The inline text expression is in there, but I don't think there are any public facing sites which let you extract it easily right now. I could probably get this up on the web sometime this weekend. Mar 19 '21 at 14:19
• MathQuill might have it, but I'm not sure. I know that MathQuill can give you the LaTeX, for example here: digabi.github.io/mathquill/test/demo.html but that has LaTeX commands in it like \frac{}{}, etc. That might just add an extra layer of string parsing if someone is implementing this. The bigger issue might be that WeBWorK is inappropriate for this type of work, no? I'm not familiar with it, but this seems like a weird hurdle for student to have to jump through. Mar 19 '21 at 15:03
• I wrote an open-source application called Spotter that is similar to webworks: lightandmatter.com/spotter/spotter.html There are three features in the software that seem to help with this. (1) Their input is rendered into non-inline "human-looking" math on the fly as they enter it. (2) If you make an error involving unbalanced parentheses, it prints out a sort of ascii-art error message showing the structure of the parens. (3) Parens can be {}, [], and (). Using these really helps a lot in seeing visually the structure of deeply nested expressions.
– user507
Mar 19 '21 at 22:29
• Offline, I would recommend LyX - graphical and once you get used to it, (i.e. keyboard shortcuts in muscle memory) you can usually even keep up with a professor on the blackboard, as long as it's just equations and no diagrams. Mar 19 '21 at 22:30

Here's an answer (but you might not like it*): Mathway.

You can intuitively create expressions in their rendered chat box. Then highlight the expression and copy and paste into a regular text box. When you do, it gives it inline.

For example, entering into Mathway the expression you mentioned:

And then highlighting, copying (I had to do a Ctrl+A to highlight it and a Ctrl+C to copy), and pasting gives: ((e^(x^(2)+7)(6x))(5x+2)-(e^((x^(2)+7)))(5))/((5x+2)^(2))

* I say you might not like it because the program is designed to help the students solve problems/cheat and you might not want your students interacting with such a site.

• @AegisCruiser: Another way, with a similar concern that Aeryk gave in the * footnote, is WolframAlpha. Mar 19 '21 at 16:27
• @DaveLRenfro Surely Wolfram|Alpha wasn't designed to help students cheat. Or are you saying instructors may not want to send their students to WA? Mar 19 '21 at 16:33
• I'm saying that if, for example, the OP wants students to factor polynomials, simplify rational expressions, evaluate the derivative of an explicitly defined function, perform some standard integration problems (indefinite or definite), etc. then pasting in the stuff at WolframAlpha pretty much defeats the purpose. If it doesn't do this for them when entering the expression, it's not going to be very difficult for them to figure out that all one needs to do is write "simplify" or "differentiate" (or $d/dx)$ before the expression. Mar 19 '21 at 16:37
• @DaveLRenfro, they will do it anyway. Concentrate on the concepts behind the manipulation. Mar 20 '21 at 17:26
• @vonbrand: For some courses --- college algebra (see course objectives on p. 2), business calculus (see p. 5), etc. --- local department course requirements may leave little wiggle room for concentrating on the concepts. If the OP is in such a situation, it's probably best not to advertise tools such as this. However, for more advanced math major courses, one would probably want to explicitly assist students' skills in using them. Mar 20 '21 at 20:54

As mentioned in the comments, Mathquill (http://docs.mathquill.com/en/latest/) allows pretty print entry (and copy/paste from other mathquill environments) and outputs latex. Khan Academy's KAS.js (https://github.com/Khan/KAS) can parse latex and output inline math. I've stuck the two together here: https://trkern.github.io/inliner.html

The output isn't optimal, since KAS makes changes to an equation's structure at the parsing stage.