# How do I check PART of an equation is correct?

**URL:** <https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919>\
**Category:** Questions\
**Tags:** patterns, validation, correctness\
**Created:** [March 14, 2021, 11:26pm UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919 "2021-03-14T23:26:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SandiG](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sandig/32/1895_2.png) [@SandiG](https://cl.desmos.com/u/SandiG)\
**Post date:** [March 14, 2021, 11:26pm UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919/1 "2021-03-14T23:26:54Z")

</div>

I have some criteria that I want students to follow, but I like the idea of leaving some choice for them in what equation to write. Does anyone know how I could check PART of their equation?

For rational functions, I could specify that the numerator must be degree three and a specific horizontal asymptote. I figured out how to check the HA with a workaround, checking their function value at an extreme x and comparing to the correct HA, but what about other criteria?

I’m thinking specifically for screen two in this activity:

> **[Dynamic feedback from graphed equations (includes student choice) • Activity...](https://classroom.amplify.com/activity/6049a57da4af48480c4d6f0e)**
>
> Screen 1: Students choose how to stretch and shift a parabola, then write an equation for their transformed parabola. Their equation is then graphed for them for visual feedback on how to improve their equation.
> 
> Screen 2: Students write equations of...

---

<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 15, 2021, 12:00am UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919/2 "2021-03-15T00:00:37Z")

</div>

For other degree and coeffiencient criteria, you can check for particular numbers using countNumberUsage, but you can’t tell where they are.

---

<div class="post-metadata">

**Author:** ![SandiG](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sandig/32/1895_2.png) [@SandiG](https://cl.desmos.com/u/SandiG)\
**Post date:** [March 15, 2021, 12:09am UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919/3 "2021-03-15T00:09:05Z")

</div>

Here’s the workaround for the HA

```auto
test2 =
when diff.evaluateAt(fn2.evaluateAt(10000), ref.cellNumericValue(2,2)) < 0.2 true
otherwise false

```

`diff` is `|x-y|` where x is the student input equation evaluated at x=10,000 and y is the exact numeric value of the HA specified in column 2 of the table.

> For other degree and coeffiencient criteria, you can check for particular numbers using countNumberUsage, but you can’t tell where they are.

Ahhh, I was hoping I was just missing something.

---

<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 15, 2021, 12:11am UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919/4 "2021-03-15T00:11:24Z")

</div>

You already read before my brain processed my mistake (solution for vertical not horizontal asymptote), so I removed it from my post.

---

<div class="post-metadata">

**Author:** ![SandiG](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sandig/32/1895_2.png) [@SandiG](https://cl.desmos.com/u/SandiG)\
**Post date:** [March 15, 2021, 12:17am UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919/5 "2021-03-15T00:17:18Z")

</div>

All good, I appreciate the replies!  
😊

---

<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 18, 2021, 2:09am UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919/6 "2021-03-18T02:09:18Z")

</div>

With new announcement and updates for the CL documentation, you may be able to parse the numerator and denominator with some of the pattern methods. Check out slide 15 in [this CL example](https://teacher.desmos.com/activitybuilder/custom/604f758ff9d2a93150073c49/edit-readonly/published#step=443fc091-75ef-4b34-8dd4-85cc6dde5f2e).

---

<div class="post-metadata">

**Author:** ![SandiG](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sandig/32/1895_2.png) [@SandiG](https://cl.desmos.com/u/SandiG)\
**Post date:** [March 18, 2021, 2:57am UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919/7 "2021-03-18T02:57:23Z")

</div>

Awesome, thank you for the heads up!

Documentation is pretty sparse. Do you know of anywhere with the pattern options written out? The script and options don’t autocomplete like others (bc beta feature?)

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [March 18, 2021, 3:30am UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919/8 "2021-03-18T03:30:38Z")

</div>

Here’s a basic fraction pattern for you to look at. Let me know if you have any further questions. [Fraction Pattern • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/6052c84b6ef7c0465559f069)

---

<div class="post-metadata">

**Author:** ![SandiG](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sandig/32/1895_2.png) [@SandiG](https://cl.desmos.com/u/SandiG)\
**Post date:** [March 18, 2021, 4:30am UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919/9 "2021-03-18T04:30:28Z")

</div>

Thank you, I appreciate the extra comments.

What type is `cellContent`? I’m trying to get it to play nice with `parse` notation like how you have but I’m not getting what I expect.

I got it to read the pure expression, but when I put `y=` at the start it breaks. I’m using `simpleFunction(parseEquation(latex).rhs)` right now so but neither `parseEquation` nor `simpleFunction` outputs latex for matching with `pattern`.

I guess I can just not `parseEquation` and remove the initial `y=`…

> **[Dynamic feedback from graphed equations (includes student choice) • Activity...](https://teacher.desmos.com/activitybuilder/custom/6052cf45f600ec4e14fb047b)**
>
> Screen 1: Students choose how to stretch and shift a parabola, then write an equation for their transformed parabola. Their equation is then graphed for them for visual feedback on how to improve their equation.
> 
> Screen 2: Students write equations of...

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [March 18, 2021, 5:15am UTC](https://cl.desmos.com/t/how-do-i-check-part-of-an-equation-is-correct/2919/10 "2021-03-18T05:15:30Z")

</div>

You’re on the right track. The pattern library only reads expressions so an equation will break it. You need to use parseEquation to separate your lhs and rhs (both strings), then match the pattern to one of those strings at a time. it’ll probably look something like

eq = parseEquation(this.cellContent(n,n))  
Fraction = patterns.fraction(patterns.expression,patterns.expression)  
Numerator = Fraction.parse(eq.rhs).numerator.latex  
Denominator = Fraction.parse(eq.rhs).denominator.latex
