# Checking Math Input for Correct Equation

Hello! I’m fairly new to Desmos CL, and I’m struggling with trying to assign correctness when a student types any version of this correct equation (4x-5=2x+3) into a math input field. I’ve searched for help from other posts in this support forum and have been trying to figure it out with parseEquation. But I just can’t figure it out. Could someone help me? Thanks!

You’re on the right track. I may not have this perfect (off the top of my head), but something close.

``````f=parseEquation(input.latex).differenceFunction("x")
check= f.evaluateAt(4)=0
``````

Thank you! That definitely worked! Especially when I added “correct: check”. I really appreciate your help!

1 Like

Thank you so much for asking this question! I was trying to use a similar code in my activity. I am having a unique issue where both 12=3(2x) and 12=3(x+2) are evaluating as “correct” even though 12=3(2x) does not correctly represent the situation. Any tips on what to add to the coding so that 12=3(2x) evaluates as incorrect?

Here is my code:

f=parseEquation(input.latex).differenceFunction(“x”)
check= f.evaluateAt(2)=0

Make a function for just the right side as well:

``````f=parseEquation(input.latex).differenceFunction(“x”)
rhs=simpleFunction(parseEquation(input.latex).rhs)
check= f.evaluateAt(2)=0 and rhs.evaluateAt(4)=18
``````

That worked! Thank you!

Do you have any suggestions for how to code to evaluate an equation like this:
x + 2y = 5x + y ?

For x+2y=5x+y

``````#creates lhs-rhs, so f(x,y)= -4x + y
f=parseEquation(input.latex).differenceFunction("x","y")
#solutions should = 0
check= f.evaluateAt(1,4)=0 and f.evaluateAt(2,8)=0
``````

If you want to ensure the lhs is x+2y, you can still do something similar (though I’m not sure when this would be necessary.

``````lhs=simpleFunction(parseEquation(input.latex).lhs,"x","y")
#add on to the check above
...and lhs.evaluateAt(0,0) and lhs.evaluate(-2,1)=0
``````
1 Like