Help with code on Inequalities

Hi,

In this activity on slide 3, solving inequalities is working well when, inside the “gok1” graph component, the teacher inputs the variables “symbol” (for the symbol of the final answer), “answer” (the final answer) and “ineq.” (the text of the inequality).

However, on slide 2, I was trying to allow students to enter those 3 variables themselves and then show all the steps to solving. I ran into an issue on slide 2, in the component gok1, with this line:

symbol= when isDefined((numericValue(gok5.labelLatex(d_1)))) ${gok5.labelLatex(d_1)} otherwise ${symbolforpremadeproblems}

answer= when isDefined((numericValue(gok5.labelLatex(d_2)))) ${gok5.labelLatex(d_2)} otherwise ${answerforpremadeproblems}

ineq=when isDefined(gok5.labelLatex(“d_3”)) "{gok5.labelLatex("d_3")}" when isDefined(gok5.labelText("d_3")) "{gok5.labelText(“d_3”)}"otherwise “${ineqforpremadeproblems}”

THE ISSUE IS BELOW:
check1a=simpleFunction(“\abs({left1}-({right1}))”,“${v}”).evaluateAt(answer)<0.001

where it is saying that the “answer” variable must be a number.

.labelLatex is the latex string from a point. For answer to be a number, you have to directly call a number from the graph, or use numericValue() to get the value of the label latex. Additionally, instead of when isDefined(thisThing) thisThing otherwise thatThing you can use firstDefinedValue(thisThing, thatThing).

answer = firstDefinedValue(numericValue(g0k5.labelLatex(`d_2`)), answerforpremadeproblems)

As long as answerforpremadeproblems is a number and not more latex, this should work.

(Forum tip: use triple backticks, or the </> button to make a block of code, then your backticks will actually display as intended.)

1 Like