Solve an equation that is typed by students

Students will have to write the two equations needed to solve and absolute value equation in the top of a table.
When they have typed the two equations correctly, they will then solve the two equations in a new table.

I have seen some much more complicated “equation” checkers that I have been unable to interpret the code.

How can I give correctness when they enter the correct x=answer in the table under the equation?

You could use something like this for each cell:

ans1= 12
cellSuffix(1,1): when this.cellHasFocus(1,1) or isBlank(this.cellContent(1,1)) ""
                 when this.cellNumericValue(1,1)=ans1 "👑" 
                 when parseEquation(this.cellContent(1,1)).differenceFunction("x").evaluateAt(ans1)=0 "✅" 
                 otherwise "❌"

You may need some kind of conditional for “ans1” depending on their input from the first table. (I’d split your “correct” variable in the first table into check1 and check2).

The code above will give no feedback if blank or currently being typed in, the crown for “x=ans1” or just ans1, a check for any equivalent form of the equation by evaluating the difference function at the solution, and an X otherwise.

Thank you for helping me out…

I saw one of your activities that seemed to actually “solve” an equation that had random A’s and B’s for. Ax+B=C , but the code was a little beyond my capabilities.

Suppose cell(0,1) contains “2x - 7 = 5”

Student enters into cell(1,1) “x = 6”

i was thinking somewhere along the lines of grabbing the right side of cell(1,1) and putting it into the lhs as a simpleFunction cell(0,1) and comparing that to the right side of cell(0,1) (difference function?)

I have an equation solver that I use for one equation, but the issue here is, I want them be able to put expr = 5 and expr = -5 in either box. So predetermining the final answer is not optimal. Not to mention, it would save a lot of editing because I would only have to change the code/problem in the first table and note.

I saw a sink for “Solve:” somewhere on an activity, but I could not understand how it worked…would that be useful?

I hope that makes sense. You are always truly helpful, and I really appreciate the time that you take to help me out.

I think I did it the way I wanted it to work. I can edit the hasFocus stuff later, but this is what I was going for.

I still ‘hack’ my way through a lot of the syntax, and when things are latex and numbers.
I am still unsure of the “{ }" stuff. Why is that sometimes when you parse an equation, the equation needs the "{ }” and sometimes not?
What returns a latex and what returns a number?
Is there a way to pass a number into latex and vice versa?

Again, I am amazed at how helpful people on the forum are.

thank you.

I’m not a dev, but I believe parseEquation( ) outputs an object of some sort. lhs and rhs output latex. differenceFunction outputs a function (lhs-rhs). evaluateAt outputs a numeric value.

Here’s what I was thinking for your activity.