Calculation Help

I am trying to get my math input to check the students answer. I have used random integers so that every time a student practices the problem they receive different values. I would love for the math input to check their work so that I can see if they did it correctly. However, I am having a hard time figuring out how to have the math input calculate the answer based on random integers.

You can add this to your input component to get a check on the teacher dashboard.

correct = simpleFunction(`-\sqrt{r^2-x^2}`, `r`, `x`).evaluateAt(note.script.b, note.script.a)=this.numericValue

correct: correct

Make sure to name your note component (I used “note”). You’ll also want to set the sketch to readOnly: true.

I have a feeling this could be a bit risky if you are testing whether a square root is equal to another value, because it could be off by a tiny bit due to computer rounding issues?

When I’m dealing with functions that aren’t very basic I tend to replace equality tests with code like the below:

diff = simpleFunction("\\operatorname{abs}(x - y)", "x", "y")
diff.evaluateAt(..., ...) <= 0.0000001