Factoring Correct Check

Is there a way to correct check this factoring problem so that they cannot type in the original polynomial?

You can use pattern matching for this - it’s a fairly new feature so not fully documented yet, but essentially adding this to your CL:

p=patterns
binom=p.product(p.expression,p.expression)
answer = function.evaluateAt(0)=6 and function.evaluateAt(1)=12 and binom.matches(this.latex)

will only accept a correct product of two expressions - ie. (x+2)(x+3) - as the answer.

1 Like

Hi. I tried that. Now it won’t do the “check”. It won’t mark it as correct or incorrect…just get the dot…

You’ve kept in the line that said correct: answer…?

yes. I tried this: This works but only allows for 1 correct answer not allowing for commutative prop. I am totally new to this and I assume I can put in an or statement or something…

function = simpleFunction(this.latex)
p=patterns
binom=p.product(p.expression,p.expression)
check1 = function.evaluateAt(-2)=0 and function.evaluateAt(-3)=0 and binom.matches(this.latex)
f=simpleFunction(text.latex)
check2=text.latex=(x+2)(x+3)
correct: check1 and check2

2 Likes

In that case, check1 handles checking of the values (through evaluateAt) and that it’s in factorised form (through binom.matches). You don’t need check2.

1 Like