Simplefunction fail with x+1

Please evaluate row 6 in the table. the correct answer is x+1. but desmos will accept 1x+1.
Is there a logic explanation and how it can be fixed ?

the activity

Looks like your C6 is looking for two numbers which 1x+1 has, but x+1 does not. Change it to 1, and it’ll work.

Alternatively you could use pattern matching (which also eliminates the need for the function):

I6= p.sum(p.literal(`x`),p.integer.satisfies(`x=1`)).matches(this.cellContent(6,2))

Thanks, understood. I thought the countusage counts number of elements in the equation. but now It is clear.
Regarding patterns, it is too advance for me right now, I need to spend some time to study it.


countNumberUsage with one parameter counts all the numbers (not digits) ignoring positive/negative signs. A fraction for example would register as two numbers. With two parameters you can count the occurence of a specific number:

#checks there are 3 numbers used:
check1= countNumberUsage(this.latex)=3
#this checks there are two 4's in the expression:
check2= countNumberUsage(this.latex,4)=2