Evaluating expressions with variables form math input

So newbie here, is there a way to evaluate a simple expression with a variable as a boolean form a math input? Can you check for an input 12x + 4 for example. I know it seems simple, but when I use latex it does NOT read any spaces.

If you’re looking for a specific expression, use simpleFunction and evaluateAt combined with countNumberUsage. Matching latex doesn’t work well (there are many threads on this topic).
Example looking for 12x+4:

input= yourInputName.latex
check= f.evaluateAt(0)=4 and f.evaluateAt(1)=16 and
 countNumberUsage(input,12)=1 and

f and input just make check a little shorter and easier to read. Linear expressions you’ll want to evaluate at a few values. Some people use graphs for their evaluations because it’s a little easier to check a whole table of values.

countNumberUsage can check the occurrences of individual numbers (not integers) as I checked for 12 and 4 above. 4 and -4 would output the same count, but evaluating expression will help distinguish any differences. You can also check how many numbers are used total by leaving out the second parameter.

1 Like