Rational Expressions (Fractions with Variables)

I’m creating an activity on multiplying and dividing rational expressions. I am using a hidden graph to generate the question and calculate what the answer should be because I want my students to simplify fractions. This works perfectly when both fractions are just numbers. But now I am on a type of problem where the numerator of one fraction will be the variable x. I have been parsing the user input so I can compare it to what the value should be that I’m calculating on my graph. But now, when I get the numerator, I want it to be a string value since they are typing something like 12x as the numerator. Is this possible?

[Unrestricted] Rational Operations - Multiplying & Dividing (with simplifying fractions) • Activity Builder by Desmos (slide 7)

Yes, you can dictate that the fraction has an expression numerator and integer denominator, and then parse the numerator latex to compare to your expected value.

Something like:

disableEvaluation: true

input = this.latex

p = patterns

frac = p.fraction(p.expression, p.integer)

num = frac.parse(input).numerator.latex
den = frac.parse(input).denominator.numericValue

check5 = num=`${graph5.number(`N`)}x` and den = graph5.number(`D`)

will do the trick.

This was perfect. Thank you!