# Check that an expression is in the correct form

**URL:** <https://cl.desmos.com/t/check-that-an-expression-is-in-the-correct-form/6836>\
**Category:** Questions\
**Tags:** patterns, validation, correctness\
**Created:** [August 15, 2024, 7:34pm UTC](https://cl.desmos.com/t/check-that-an-expression-is-in-the-correct-form/6836 "2024-08-15T19:34:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_McSorley](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/kevin_mcsorley/32/1563_2.png) [@Kevin\_McSorley](https://cl.desmos.com/u/Kevin_McSorley)\
**Post date:** [August 15, 2024, 7:34pm UTC](https://cl.desmos.com/t/check-that-an-expression-is-in-the-correct-form/6836/1 "2024-08-15T19:34:23Z")

</div>

Does anyone have a way to check that an expression is in the correct form? For example, when students are given a^m\*a^n I want them to enter a^(m+n), I know how to do this for expressions containing numbers by using countNumberUsage(), but I am not sure what to do if the expression only contains variables since the student can just copy/paste the original expression. Here is an activity with an example: [https://teacher.desmos.com/activitybuilder/custom/66be571be37c84295a8b7199](https://teacher.desmos.com/activitybuilder/custom/66be571be37c84295a8b7199)

---

<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:** [August 17, 2024, 12:05am UTC](https://cl.desmos.com/t/check-that-an-expression-is-in-the-correct-form/6836/2 "2024-08-17T00:05:40Z")

</div>

Since it’s a pretty specific form you want, a pattern seems like a possible approach, using patterns.literal(“n”). Something like this: [[Copy of] Check Expression • Activity Builder by Desmos Classroom](https://teacher.desmos.com/activitybuilder/custom/66bfbc8f9f98722b5cf384ea)

---

<div class="post-metadata">

**Author:** ![Kevin\_McSorley](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/kevin_mcsorley/32/1563_2.png) [@Kevin\_McSorley](https://cl.desmos.com/u/Kevin_McSorley)\
**Post date:** [August 17, 2024, 2:40am UTC](https://cl.desmos.com/t/check-that-an-expression-is-in-the-correct-form/6836/3 "2024-08-17T02:40:54Z")

</div>

That’s great! I haven’t used patterns before. I just watched Jay’s video from a few years ago introducing patterns and now I can’t wait to learn more. Thanks so much!

---

<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:** [August 17, 2024, 9:04pm UTC](https://cl.desmos.com/t/check-that-an-expression-is-in-the-correct-form/6836/4 "2024-08-17T21:04:55Z")

</div>

No problem - I didn’t realize that you didn’t already use patterns. There is a series of patterns videos on the Desmos YouTube channel that are really helpful.
