# Checking correctness of an equation

**URL:** <https://cl.desmos.com/t/checking-correctness-of-an-equation/2116>\
**Category:** Questions\
**Tags:** patterns, validation, correctness\
**Created:** [December 7, 2020, 4:56pm UTC](https://cl.desmos.com/t/checking-correctness-of-an-equation/2116 "2020-12-07T16:56:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alyshea\_Moore](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/alyshea_moore/32/1161_2.png) [@Alyshea\_Moore](https://cl.desmos.com/u/Alyshea_Moore)\
**Post date:** [December 7, 2020, 4:56pm UTC](https://cl.desmos.com/t/checking-correctness-of-an-equation/2116/1 "2020-12-07T16:56:01Z")

</div>

I want students to be marked correct when they type in math input the equation y = 30x-6 as well as equivalent forms of slope such as y = 60/2 x -6. How do I do this in CL?

---

<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:** [December 7, 2020, 6:52pm UTC](https://cl.desmos.com/t/checking-correctness-of-an-equation/2116/2 "2020-12-07T18:52:12Z")

</div>

```auto
myLine=xyLine(this.latex) #makes a line object

#I'm rounding below in case you want to apply to slopes that would be 
#longer or non-terminating decimals
slope=numericValue("\round(${myLine.slope},1)") 

yInt=myLine.yIntercept
check= slope=30 and yInt=-6
correct: check

```

The above will accept in any form. If you want to limit to slope-intercept form, add:

```auto
f=simpleFunction(parseEquation(this.latex).lhs,"y")
slopeIntForm=f.evaluateAt(0)=0 and f.evaluateAt(2)=2

```

Then, add “`and slopeIntForm`” to `check`

---

<div class="post-metadata">

**Author:** ![Jonathan\_Sandoval](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jonathan_sandoval/32/1316_2.png) [@Jonathan\_Sandoval](https://cl.desmos.com/u/Jonathan_Sandoval)\
**Post date:** [January 5, 2021, 10:01pm UTC](https://cl.desmos.com/t/checking-correctness-of-an-equation/2116/3 "2021-01-05T22:01:34Z")

</div>

This is awesome and will no doubt save me so much time! Is there a way to limit to standard form as well?

---

<div class="post-metadata">

**Author:** ![Jonathan\_Sandoval](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jonathan_sandoval/32/1316_2.png) [@Jonathan\_Sandoval](https://cl.desmos.com/u/Jonathan_Sandoval)\
**Post date:** [January 5, 2021, 10:24pm UTC](https://cl.desmos.com/t/checking-correctness-of-an-equation/2116/4 "2021-01-05T22:24:18Z")

</div>

Also I’m trying to have student students enter slope as 2/3 and I’m not able to get it to show as correct. Am I missing anything?

---

<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 6, 2021, 12:15am UTC](https://cl.desmos.com/t/checking-correctness-of-an-equation/2116/5 "2021-01-06T00:15:18Z")

</div>

You need your `slope=` in `check` to be a terminating decimal.

If you want specific forms, you can additionally use `countNumberUsage`. For example, `2x+3y=-3` you could use:  
`...and countNumberUsage(this.latex,2)=1 and countNumberUsage(this.latex,3)=2`

Note that checking for the number 3 needs to occur twice, even though one of them is negative. You can’t use negative numbers in countNumberUsage, but the evaluations generally take care of any ambiguity.

You can use similar methods for slope intercept form.

---

<div class="post-metadata">

**Author:** ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)\
**Post date:** [March 7, 2022, 10:54pm UTC](https://cl.desmos.com/t/checking-correctness-of-an-equation/2116/6 "2022-03-07T22:54:47Z")

</div>

I am trying to adapt your coding here for my activity. I want the correct answer to be in slope intercept form and `y=-x+2`. This is what I have but it is not showing as correct when I test it.

myLine=xyLine(this.latex)

slope=m1.numericValue

yInt=myLine.yIntercept  
check= slope=-1 and yInt=2 and slopeIntForm  
correct: check

f=simpleFunction(parseEquation(this.latex).lhs,“y”)  
slopeIntForm=f.evaluateAt(0)=2 and f.evaluateAt(2)=0

disableEvaluation: true

showSubmitButton: true

submitLabel: “Check my Answers”

resetLabel: when this.submitted (when check “✅” otherwise “❌”) otherwise “”

---

<div class="post-metadata">

**Author:** ![pirsquared](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pirsquared](https://cl.desmos.com/u/pirsquared)\
**Post date:** [March 7, 2022, 11:04pm UTC](https://cl.desmos.com/t/checking-correctness-of-an-equation/2116/7 "2022-03-07T23:04:57Z")

</div>

> [@Pamela\_Davis](#):
>
> slopeIntForm=f.evaluateAt(0)=2 and f.evaluateAt(2)=0

If this isn’t a typo here then this is the bit that’s wrong, I think - it should be

```auto
slopeIntForm=f.evaluateAt(0)=0 and f.evaluateAt(2)=2

```

All this is doing (as far as I can tell) is checking that the LHS contains y and y only, not y+5=… or similar.

You could also force y only by using pattern matching, as we were looking at in the other thread.

---

<div class="post-metadata">

**Author:** ![Matt\_Harmless](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/matt_harmless/32/6497_2.png) [@Matt\_Harmless](https://cl.desmos.com/u/Matt_Harmless)\
**Post date:** [February 27, 2026, 1:53pm UTC](https://cl.desmos.com/t/checking-correctness-of-an-equation/2116/8 "2026-02-27T13:53:16Z")

</div>

I really like this code for students putting their answers is slope-intercept form, but now I am having trouble with a secondary issue. I like to put a slide at the end of the activity that shows which slides were correct and which were incorrect. I also like to put a message after the input to say it was correct or if they need to try again. I normally do this by simply matching the answer.latex with what is supposed to be there , but when the correctness is checked this way, I don’t know how to translate that to a separate component or a separate slide.

---

<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:** [February 27, 2026, 2:02pm UTC](https://cl.desmos.com/t/checking-correctness-of-an-equation/2116/9 "2026-02-27T14:02:30Z")

</div>

> [@Matt\_Harmless](#):
>
> when the correctness is checked this way, I don’t know how to translate that to a separate component or a separate slide.

It looks like normally what you’re doing is rechecking student answers. In this code, `check` is the variable being used for correctness, so rather than rechecking will just use this boolean value, which is true when correct, in whatever `when-otherwise` you’d normally use:

```auto
message = 
  when inputName.script.check "✅ You got it!"
  otherwise "❌ Try again."

```

You can reference any variable in another component using the form:

```auto
componentName.script.variableName

```

This can be much more convenient than re-correcting each screen, just have a `check` or `correct` variable for each screen, and then you’re not doing double duty.
