Reading correct answer when inputting a function

In my programs I know how to code it to when a student inputs an answer the text will change to say it is correct. A problem I run into is that for some functions they write, there are many ways to write the function and I have to end up making 10 solution possibilities all for the same function. Is there a way to make demos read the function itself and compare it to a default function for accuracy?

If it’s a linear function, I usually use xyLine to check for correctness. If not, I’ve used evaluateAt. You can use some arbitrary number that probably will give a unique output and see if that matches with the intended output. It’s not fool proof, but it usually works.

1 Like

So the 9 in your evaluateAt(9) is just a random number?

Follow up question, is there anything like this for coordinates? to where if they enter in a coordinate with spaces or no spaces it will be read the same?

Correct, I chose 9 randomly.

You do have the ability to read coordinates without the headaches of coding it. Try parseOrderedPair. There’s an example in the documentation.

https://teacher.desmos.com/computation-layer/documentation#functions:parseOrderedPair

2 Likes