# Checking correctness of standard form of equations

**URL:** <https://cl.desmos.com/t/checking-correctness-of-standard-form-of-equations/7769>\
**Category:** Questions\
**Tags:** validation, correctness\
**Created:** [February 25, 2025, 6:15pm UTC](https://cl.desmos.com/t/checking-correctness-of-standard-form-of-equations/7769 "2025-02-25T18:15:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phillip\_Hubbard](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/phillip_hubbard/32/4122_2.png) [@Phillip\_Hubbard](https://cl.desmos.com/u/Phillip_Hubbard)\
**Post date:** [February 25, 2025, 6:15pm UTC](https://cl.desmos.com/t/checking-correctness-of-standard-form-of-equations/7769/1 "2025-02-25T18:15:16Z")

</div>

Hello! I have an activity where I want students to input 2 equations in standard form and have the coding indicate correctness for multiple formats of the same form. The two equations are x + y = 28 and 4x + 6y = 144. I want the coding to mark the answers as correct if they switch the variables such as y + x = 28 or 6y + 4x = 144, and also mark correct if they lead with the constant instead such as 28 = x + y, etc. Here’s what I have so far: [Standard Form](https://teacher.desmos.com/activitybuilder/custom/67be068aa9628559fc635ff1)

Any help is appreciated! Thank you.

---

<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 25, 2025, 6:34pm UTC](https://cl.desmos.com/t/checking-correctness-of-standard-form-of-equations/7769/2 "2025-02-25T18:34:39Z")

</div>

Pretty close! For the first input, your pattern requires a number. So for line 6 you can adjust your pattern and make it optional. The sum pattern already allows for any order, but if you ever desire it you can add `.strictOrder` to modify it.

```auto
lhs = p.anyOf(p.sum(p.product(p.optional(p.number),(x)), p.product(p.optional(p.number),y)))

```

For allowing the reverse equation, just add a check for the rhs to you lhsmatch:

```auto
lhsmatch = lhs.matches(expr.lhs) or lhs.matches(expr.rhs)

```

The other reason it’s not working is evaluating your difference function with those ordered pairs do not equal 0 because they’re not solutions to the equation.

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [February 25, 2025, 6:34pm UTC](https://cl.desmos.com/t/checking-correctness-of-standard-form-of-equations/7769/3 "2025-02-25T18:34:43Z")

</div>

Are you familiar with xyLine()?

If you use that instead of simpleFunction it will save a lot of grief. It will take a line in any format and then you can just check its slope and intercept values. This will also let you deal with vertical lines.

Let me know if you’d like an example.

---

<div class="post-metadata">

**Author:** ![Phillip\_Hubbard](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/phillip_hubbard/32/4122_2.png) [@Phillip\_Hubbard](https://cl.desmos.com/u/Phillip_Hubbard)\
**Post date:** [February 26, 2025, 2:09pm UTC](https://cl.desmos.com/t/checking-correctness-of-standard-form-of-equations/7769/4 "2025-02-26T14:09:47Z")

</div>

Thank you, this worked perfectly!

---

<div class="post-metadata">

**Author:** ![Phillip\_Hubbard](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/phillip_hubbard/32/4122_2.png) [@Phillip\_Hubbard](https://cl.desmos.com/u/Phillip_Hubbard)\
**Post date:** [February 26, 2025, 2:10pm UTC](https://cl.desmos.com/t/checking-correctness-of-standard-form-of-equations/7769/5 "2025-02-26T14:10:13Z")

</div>

Thanks for the reminder about xyLine()!
