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

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:

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

Here’s the workaround for the HA

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

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

All good, I appreciate the replies!

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.

1 Like

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?)

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

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

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

1 Like