Patterns Product and Trig Functions

Pretty sure this is a bug but thought I’d ask here first.

The Patterns schema for Products has some inconsistent expression handling I’ve seen in the past, and I’m guessing this is more of that. Here goes:

Desmos thinks that an expression like 2\cos\left(x\right) is not a product but 2\cos x somehow is.

And it thinks \cos\left(x\right)\sin\left(x\right) is not a product at all either and not \sin\left(x\right)\cos x either, even though it happily thinks that earlier 2\cosx example is.

And finally it thinks something like plain old \sin\left(x\right) is a product.

Similar story for other functions like log, etc. and a lot of stuff with parentheses.

Kind of interesting… but fairly frustrating since it renders products unuseable for trig functions and others.

Any thoughts?

Oh, here’s a quick demo to illustrate: prod testing • Activity Builder by Desmos Classroom

I believe it’s a known issue, having seen it with function notation. Below does seem to at least allow patterns to recognize it as a product, although parsing it is not reliable. When something like “sin(x)cos(x)” is entered it parses \sin as the first term, x for the second, etc. The same expression without parentheses yields “undefined”.

prod = p.product(p.repeat(p.anyOf(p.literal(`\sin(x)`), p.literal(`\cos(x)`), p.expression)))
prodValid = prod.matches(this.latex)

#leading term
termA = prod.parse(this.latex).term1.nth(1).latex

You may find p.functionCall useful for identifying use of trig functions in an answer.


identifier” is the function name, “n” the number of arguments in the function, and “nth( )” will allow you to parse the latex for a particular argument.

Yeah that’s what came to mind, I’ll have to go down that route, just not sure it’s worth it.

Thanks

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.