CL to check complex numbers

I want to make a self-checking activity with complex number arithmetic. Is there a way I can check student answers without using latex?

Yes, you can consider the input as a function with i as an input variable, and then use test values to compare the student’s answer to the actual answer. You also need to use patterns to make sure their answer is in the right form, or else it would give correct for just copying and pasting the question, for example.

Wow. This is amazing CL.

So the addition of the variables a1, b1, a2, and b2 in the input CL allow me to change the problem on a following slide by changing those values. And I see how the simpleFunction command allows me to check the value. I actually played with that before I asked for help but I didn’t know how to make the variable i.

The commands after pattern are completely new to me and I’m trying to figure out how they work. Does the valid command define that variations like -9+i, i-9, i±9, and -9-(-i) are all the same? And then the structureCheck command compares the input latex to all of the latex forms defined in the valid command?

Glad to help! Putting the values as variables does make it easier to make additional slides. It’s also useful if you want to create repeated, randomized practice, because you can attach random number generators to the values.

The pattern stuff is the way Desmos handles pattern matching. It can take a while to understand how it works. Basically, you set up valid pattern templates that define the forms you want to allow, and then you can call the .matches method to get a boolean to see if input matches that form. You can also use the .parse method to extract values from the student input.

So I set up all the possible ways the answer could be (well, except if it was a division problem, will need to modify to allow for fractions). Then the anyOf function allows you to match against any of those patterns.

Desmos has a series of videos that show how to use patterns - they’re pretty critical to learn both for self-checking, but also for extracting meaning from student input and responding to it.