Question about patterns with randomized exponent problems

Hi all - someone on FB was asking for help with trying to make a randomized practice screen for simplifying exponents. I’ve been thinking about it, but I’m not sure how to do this. So the general problem would be in the form (a * x^b * y^c)^d * (e * x^f * y^g )^h, where variables a - h are randomized integers. The goal is to have the student write it as a simplified expression, without negative exponents. So each variable could end up either on the top or bottom, with an exponent that is a positive integer, or no exponent if it comes to 1, or the variable disappears completely if the exponent comes to 0. And the coefficients as well will either be just in the numerator, just in the denominator, or both.

It’s easy enough to check if the student’s expression is equivalent to the given problem, but with all of the possible permutations of the answer, I’m not sure how to write patterns in an efficient way to trap all possibilities and still ensure that the student has the simplest answer.

Any thoughts on this?

I thought I had an efficient solution for checking if an expression is simplified, but it became rather convoluted when I actually typed it up :upside_down_face:

I maintain that the bones of the solution are straightforward:

  • Use patterns to check that the numerator and denominator (or entire expression if not a fraction) have the form a * x^b * y^c where b, c are both greater than 1
  • Use substituteLatexVariable and countNumberUsage to check that x and y both appear at most once
  • Get the coefficients for the numerator and denominator (by setting x and y to 1) to check that their greatest common factor is 1

The lines of CL code doubled once I added additional considerations, namely, where negative signs can occur and when +/- 1 is allowed to appear. Here it is in action:

I’ve fixed the bugs I could find, but I would be surprised if I caught them all. Even if the overall solution is less than ideal, hopefully it includes some useful ideas!

Thanks for thinking about it. I’ll take a look at your solution. I came up with a different way to do it today, basically determining what the numerator and denominator answers should be, turning them into functions, and then comparing them against the numerator and denominator functions of the answer. Avoided patterns that way. (screen 4)

1 Like

I like that your solution avoids patterns. How does it handle cases when one or both coefficients evaluate to 1 - does it expect students to type the 1? I wasn’t sure as I read through the code.

They don’t need to type the 1, because I am converting the numerator and denominator into separate functions, and then comparing test values in the student functions to the correct simplified functions. So it would give correct if any equivalent function is used. For example if it was supposed to be x^5 and they wrote x^2 x^3 it will mark correct. But I figured that this is close enough. Could probably add in the substituteLatex truck and count number usage to prevent this but I ran out of steam on it.

Ah, right. Thanks for clarifying!