# Evaluating expressions with variables form math input

**URL:** <https://cl.desmos.com/t/evaluating-expressions-with-variables-form-math-input/1426>\
**Category:** Questions\
**Created:** [September 4, 2020, 2:59am UTC](https://cl.desmos.com/t/evaluating-expressions-with-variables-form-math-input/1426 "2020-09-04T02:59:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rickp11](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/rickp11/32/836_2.png) [@Rickp11](https://cl.desmos.com/u/Rickp11)\
**Post date:** [September 4, 2020, 2:59am UTC](https://cl.desmos.com/t/evaluating-expressions-with-variables-form-math-input/1426/1 "2020-09-04T02:59:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [September 4, 2020, 5:07pm UTC](https://cl.desmos.com/t/evaluating-expressions-with-variables-form-math-input/1426/2 "2020-09-04T17:07:04Z")

</div>

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`:

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

```

`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.
