Self Checking Expression CL?

I want to find out how to write code that will take a student’s input of, let’s say x^2+2hx+h^2 and mark that answer as correct if my version was x^2+h^2+2xh. I have been trying to use string matching but it doesn’t really work for the students unless I tell them how to format, in which case I guide them towards an answer which I don’t like.

Looking at the CL options, it looks like I may want to use the differenceFunction because the differenceFunction between the student input and the one I write should be 0, but how exactly do I structure/write the code?

(I’m trying to figure out this 2-variable example so that I can modify the CL for 1-variable responses too).

Hey Atilano!

Two questions:

  1. Are you asking for a formula here or will they be using numbers in there for h?
  2. Are you specifying that this expanded form be used or do you just want any equivalent expression?

I’m asking for a formula and I want students to enter their expanded form for a difference quotient. I figured the two variable h, (to give students a chance to work with literal equations and strengthen their algebra skills).

Someone shared this code and it works! In case you have any additional notes I should consider?

This should be your function for c. When evaluating C and U, you should use more than one solution to check a quadratic.