Latex Expression Matching

I see this request a lot on here, and the usual answer is usually to avoid even trying to do this, but it’s such a useful thing to be able to do and so many people continue to ask for it, I came up with something I think will effectively do this for most people.

You want to check if a student’s algebra is correct. So maybe they’re rewriting something, maybe factoring a quadratic, maybe expanding, possibly something much more complex such as simplifying the sum of several rational expressions.

This is borderline impossible to do. There are just too many equivalent ways of writing expressions.


  • Create a robust data table whose output corresponds to the student’s answer expression
  • Compare the data set to that data set formed by the initial expression
  • Check that the difference in residual totals goes to zero(or as the limit approaches zero if you prefer some flexibility when it comes to certain situations)
  • Rinse and repeat

There are are edge-cases I can imagine that might not work so well with this but let me know what you think!

Here’s an activity that does what I’m talking about: Equivalent Expression Check | :infinity: Question Bank

This is actually the recommended way (perhaps in less lines) to check functions! Great work!

Ah great!

Every post i noticed about this before said to use evaluateAt for a few points, but to just avoid trying this altogether as it wouldn’t be too reliable.

If there’s a more terse way of writing it up, by all means edit away! This was more of a stream of consciousness build.

Looks great, I like your version. Totally digestible.

Difference between this and evaluating at a few points is CL inability to perform list operations. Huge bummer when the author doesn’t want a graph on the screen. Hiding the graph might be an option there but if center column text and input is desired, even a hidden graph will change the arrangement.

I guess we could essentially do this in CL with two simpleFunctions, but every point of evaluation would have to be written out (at least the first time).

Right, makes sense.

I wonder if there’s some utility in a separate “graph-esque” component whose entire purpose is to do the calculations, sans graph. That might be asking for too much, considering.

I think in the past I’ve used the opening screen graph as a dummy animation welcome thing, but really just used it as a proxy container for other panels.

I have a different method for the negative values and expression display. It also removes 1 as a coefficient.

1 Like

Nice, i like that!

I considered getting rid of the leading 1 but didn’t. I like getting rid of it better though!

Do you have this code embedded in the activity anywhere, or do I need to copy it myself?

Here you are:

1 Like

The link comes up with “Activity Not Found.”

Sorry, I was trying to clean up some of my activities by combining some example stuff into one activity, and I deleted that part out. You can still see in the image above though. :man_shrugging:

Got it and completely understand. No problem. Thanks!