parseEquation from Table

Hi Everyone,

Quick question - is there a way to parse an equation from a table? I’m having students enter the equations of lines into tables that are randomly generated. However my code as it stands right now can’t handle vertical lines. So when a student inputs x=3 for instance, it reads as incorrect (even if there’s a vertical line at x=3)

What I’d like to be able to do is parse the lhs or rhs of the equation and do a check against my randomly generated questions.



Have you tried using parseEquation( ).differenceFunction(“x”,“y”)? In the graph, you’d use f(x,y)=0 to graph it.

How are you “correcting” their input? Can you share your activity?

Hi Daniel,

Here’s a link to my acitivty: Key Skills - Calculus • Activity Builder by Desmos

It’s still a draft at this point - I’m talking about slide 3.

The way I’m generating prompts is to randomly generate an (x1,y1) and (x2,y2) point and then using them to create a line. However sometimes x1 and x2 end up being the same - which I do want so they get practice with vertical lines. However I am unsure how to pick apart the equation that they will enter and compare to x1 for instance.

Thank you!

You might look into “xyLine”. It has “.isVertical” to check for undefined slopes.

It also doesn’t look like you’re doing any function comparisons to check for correctness. Here’s a link to a method to run multiple values through a target function and a student function to check their equivalence. (Note: function g would be defined in the CL.)

This method does not differentiate different forms of an equation, only verifying equivalence, but it could handle vertical lines without any problem. You may want to look at pattern matching to distinguish between point-slope and slope-intercept forms.