# Checking Math Input for Correct Equation

**URL:** <https://cl.desmos.com/t/checking-math-input-for-correct-equation/2454>\
**Category:** Questions\
**Tags:** validation, correctness\
**Created:** [January 21, 2021, 10:23pm UTC](https://cl.desmos.com/t/checking-math-input-for-correct-equation/2454 "2021-01-21T22:23:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Melinda\_O](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/melinda_o/32/714_2.png) [@Melinda\_O](https://cl.desmos.com/u/Melinda_O)\
**Post date:** [January 21, 2021, 10:23pm UTC](https://cl.desmos.com/t/checking-math-input-for-correct-equation/2454/1 "2021-01-21T22:23:04Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [January 22, 2021, 2:58am UTC](https://cl.desmos.com/t/checking-math-input-for-correct-equation/2454/2 "2021-01-22T02:58:53Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![Melinda\_O](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/melinda_o/32/714_2.png) [@Melinda\_O](https://cl.desmos.com/u/Melinda_O)\
**Post date:** [January 22, 2021, 3:54pm UTC](https://cl.desmos.com/t/checking-math-input-for-correct-equation/2454/3 "2021-01-22T15:54:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kschweiss](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kschweiss](https://cl.desmos.com/u/kschweiss)\
**Post date:** [March 16, 2021, 4:00pm UTC](https://cl.desmos.com/t/checking-math-input-for-correct-equation/2454/4 "2021-03-16T16:00:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [March 16, 2021, 4:31pm UTC](https://cl.desmos.com/t/checking-math-input-for-correct-equation/2454/6 "2021-03-16T16:31:38Z")

</div>

Make a function for just the right side as well:

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

```

---

<div class="post-metadata">

**Author:** ![kschweiss](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kschweiss](https://cl.desmos.com/u/kschweiss)\
**Post date:** [March 16, 2021, 6:35pm UTC](https://cl.desmos.com/t/checking-math-input-for-correct-equation/2454/7 "2021-03-16T18:35:13Z")

</div>

That worked! Thank you!

---

<div class="post-metadata">

**Author:** ![kschweiss](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kschweiss](https://cl.desmos.com/u/kschweiss)\
**Post date:** [April 9, 2021, 8:16pm UTC](https://cl.desmos.com/t/checking-math-input-for-correct-equation/2454/8 "2021-04-09T20:16:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [April 9, 2021, 9:08pm UTC](https://cl.desmos.com/t/checking-math-input-for-correct-equation/2454/9 "2021-04-09T21:08:47Z")

</div>

It’s almost identical. You just need to add an additional parameter.  
For x+2y=5x+y

```auto
#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.

```auto
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

```
