# Capturing a latex expression from an Input component

#1

Hello! I want to test if a student has entered a correct equation in an Input component
I can get a ‘when’ command to understand

using

when functionInput.submitted and functionInput.latex=“3x^2”

but if I want

with a 3 ‘dot’ 2 and x-1 in the exponent position, CL doesn’t recognize it. Tried looking up Latex code, and using various variations of ‘cdot’ for the center hasn’t doesn’t worked. Help!

*note: apologies if my equation images didn’t come through…

#2

You could try using two backslashes before the cdot e.g. \\cdot

But I also think that the trying to match exact strings like this is likely to be brittle because if a student adds a space or parentheses then the string match will fail.

#3

works! thanks! I didn’t try try putting the \ right before cdot…I tried this \3cdot2, instead of 3\cdot2, which works. True word about the brittleness, but I like to give the kids a chance at immediate feedback…

#4

The usual way to check if an expression is equivalent to your answer is to pass them into the calculator and evaluate both functions at a handful of values to test whether they have the same ouptut. That way, you don’t have to try to guess what inputs to accept.

#5

Thanks! That’s what I ended up doing. I wanted to have the students produce an expression with a certain format, but that’s probably better as a part of a class discussion anyway.