Good day
Working with a gap fill mathematical expression.
For context, this is a high school activity working on developing products in the form of a quadratic trinomial.
I want to match for the product of a monomial and a polynomial with the following specifications:
- form 𝑥(𝑦) where 𝑥 is a monomial and 𝑦 is a polynomial
- 𝑥 may not be omitted or empty
- 𝑥 must be a number, unless it contains any number of variables with or without exponents, in which case it may also contain a number
This is my current pattern:
`+-((($n`?($v^($n)`?)`+)`|($n))((`+-($n`?($v^$n)`+)) + (`+-($n`?($v^($n)`?)`+))`+ + (`+-(($n`?($v^$n)`+)`|$n))))
Which NUMBAS renders as:
From my understanding, the "or number" section (`|($n)) for 𝑥 is causing trouble, though it may also be the quantifiers.
I want the pattern to be able to accept both of the following,
- -3a^2(6a^2-3ab+10ab-5b^2)
- 3(6a^2-3ab+10ab-5b^2)
but NOT: