Analyse LaTeX from MathInput

Hey everyone,
I would like to decide whether a LaTeX input of a student is correct. I have seen two posts solving this when the input is of the form y = 3x + 14 for example. I tried the exact same method for the following expected input: =800-100, more precisely:

correct = this.latex = `=800-100`

However, this code doesn’t work. I tried again without the additional “=” which then worked. Unfortunately, I really want to have this additional “=” in front of the expression.

Does anybody have an idea why this additional “=” disturbs the above approach and how a workaround could look like?
Thanks for any idea!

I have a workaround now, but it is very complicated, so I am still happy for any suggestion.

My workaround:
Add a hidden math input, set initialLatex to the one I want and then check for

correct = "${this.latex}" = "${checkEntry.latex}"

This works, but it is absolutely necessary that I put ${} instead of simply

correct = this.latex = checkEntry.latex

which doesn’t work…

In this vein, did you try quotes with your original?

correct = "${this.latex}" = "${`=800-100`}"

Edit: I thought the benefit of this was that the latex inside ${ } would eliminate extra spaces, but it doesn’t. @Susan_Lauer’s below seems simplest, but won’t handle extra spaces.

I think because “=800-100” in the Desmos calculator generates an error is the reason it’s not working, but not sure.

It should have been:
correct = this.latex = "=800-100"

I don’t exactly see the difference with my initial approach… Is it that you exchange the ` by "?

Finally, I found a way to cope with additional spaces. It is a very weird workaround, but here is how I did it in the end:

correct = parseEquation("3${this.latex}").rhs = `whatever LaTeX I expect after the "="`

To use the parseEquation, I need to artificially insert something on the lhs of the equation. Afterwards, it works just as expected. There is no different if I put 3 or something else, it was simply the first thing that came to my mind…

I really hope that pattern recognition will soon be available, or some sort of more powerful scripting like python!

1 Like

I hadn’t tried that! Thanks in any case :slight_smile: See below for my workaround which copes with additional spaces!
Your explanation with the error inside the calculator seems plausible…