ExpressionPatternMatch example?

Hi. A lot of the computation layer documentation is lacking code examples. Was hoping to solve this mystery.

I have a table where I ask student to enter responses to questions where students have to reduce a radical into simplified radical form. So if I give them a randomly generated question like \sqrt{72} and expect 6*\sqrt{2} as an answer, I am trying to build in correctness. So far,

check1 =
when this.cellNumericValue(1,2)= simpleFunction(“\sqrt{f}”,“f”).evaluateAt(a) 1
otherwise 0

This code checks if their answer evaluates to \sqrt{72} but I am trying to also find a way to check their latex input if it is reduced to simpified form by checking to see if there is a \sqrt{prime}. I am hoping maybe ExpressionPatternMatch can help with this but I do not know how to implement it? Or is there something else?

Hey mark!

Pattern matching is a feature that is used in our advanced editing process and is not publicly consumable.

If you want to check for a particular form you could use a combination of numericValue and countNumberUsage.

Adding countVariableUsage and countOperatorUsage and maybe countFunctionUsage would go a long way towards enabling form checking scenarios. Like countVariableUsage("(x-1)(x+5)(x-3)", “x”) would be 3, and countOperatorUsage("(x-1)(x+5)(x-3)", “^”) would be 0, and maybe countFunctionUsage(“3*\sqrt{5}”, “sqrt”) would be 1.

1 Like

Hey Jay!
Is there any hope that pattern recognition will be publicly accessible in the future? It would open a lot of opportunities to adapt feedback for the students!

3 Likes