Operating with expressions

I would like to take entries from a table say cell 1,1 and cell 1,2 and verify their product.

For example, if students input 2x and 3x as the entries in the table, I want to check that the product is 6x^2. Is there a way to do this?

By the way, I have code that will check that 2x is in cell 1,1 and 3x is in cell 1,2 but it takes extra coding if students put 3x in the cell 1,1 and 2x in cell 1, 2. I am looking for help with writing one code that would work with both.

You can set variables for the two expressions and the expected (desired?) product (e.g. exp1, exp2, expProduct), then compare evaluations:

check = simpleFunction("${exp1}*${exp2}").evaluateAt(3)=simpleFunction(expProduct).evaluateAt(3) and simpleFunction("${exp1}*${exp2}").evaluateAt(4)=simpleFunction(expProduct).evaluateAt(4)

(Note: I used ${ } for the the two expressions because you need to multiply them which makes the quotes necessary. expProduct (as long as it it latex) doesn’t need it because it’s just the one expression.

1 Like

That is exactly what I needed to know. I was close but didn’t know about the quotation marks. Thanks!