# Parsing equation with different input variables

**URL:** <https://cl.desmos.com/t/parsing-equation-with-different-input-variables/3834>\
**Category:** Questions\
**Tags:** simplefunction\
**Created:** [November 15, 2021, 3:44pm UTC](https://cl.desmos.com/t/parsing-equation-with-different-input-variables/3834 "2021-11-15T15:44:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![valeriek](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/valeriek/32/851_2.png) [@valeriek](https://cl.desmos.com/u/valeriek)\
**Post date:** [November 15, 2021, 3:44pm UTC](https://cl.desmos.com/t/parsing-equation-with-different-input-variables/3834/1 "2021-11-15T15:44:22Z")

</div>

I understand how to allow different input variables, as shown in this activity:

[https://teacher.desmos.com/activitybuilder/custom/6063559df537583ea4cdadf8](https://teacher.desmos.com/activitybuilder/custom/6063559df537583ea4cdadf8)

But I’d also like to parse the input. At the moment my code is:

function(“f”): simpleFunction(parseEquation(function3.latex, “n”).rhs)

But it’s not working.

Thank you!!

---

<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:** [November 15, 2021, 4:41pm UTC](https://cl.desmos.com/t/parsing-equation-with-different-input-variables/3834/2 "2021-11-15T16:41:00Z")

</div>

The .rhs is a latex output of the right hand side, so needs to go after it:

```auto
function(“f”): simpleFunction(parseEquation(function3.latex).rhs, “n”)

```

---

<div class="post-metadata">

**Author:** ![valeriek](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/valeriek/32/851_2.png) [@valeriek](https://cl.desmos.com/u/valeriek)\
**Post date:** [November 16, 2021, 10:17am UTC](https://cl.desmos.com/t/parsing-equation-with-different-input-variables/3834/3 "2021-11-16T10:17:53Z")

</div>

Of course!! Thank you so much, Daniel.

---

<div class="post-metadata">

**Author:** ![valeriek](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/valeriek/32/851_2.png) [@valeriek](https://cl.desmos.com/u/valeriek)\
**Post date:** [November 20, 2021, 2:22pm UTC](https://cl.desmos.com/t/parsing-equation-with-different-input-variables/3834/4 "2021-11-20T14:22:34Z")

</div>

I have a follow-up question. Is it possible to have an input variable be two letters? In this case, the students will be using the interest formula, and the input is `PV`.

Here’s the code that I have so far. It works with a single-letter input like “x” or “n”, but not with `PV`.

right = parseEquation(this.latex).rhs

check1 = simpleFunction(right,`PV`).evaluateAt(7215.74283) \> 9990 and simpleFunction(right,`PV`).evaluateAt(7215.74283) \< 10010

suffix:  
when this.submitted and check1 “✅”  
when this.submitted and not(check1) “❌”  
otherwise “”

initialLatex: `10000 = `  
correct: check1

disableEvaluation: true

---

<div class="post-metadata">

**Author:** ![Elayna](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/elayna/32/2253_2.png) [@Elayna](https://cl.desmos.com/u/Elayna)\
**Post date:** [November 20, 2021, 3:30pm UTC](https://cl.desmos.com/t/parsing-equation-with-different-input-variables/3834/5 "2021-11-20T15:30:11Z")

</div>

Yes, you can use multiple variables with simpleFunction. It might look something like this:

```auto
check1 = simpleFunction(right, "P","V").evaluateAt(insertNumberforP,insertNumberforV)...

```

Just list the variables after the source in quotes, and when evaluating, list the values of the variables (2 for 2 variables, 3 for 3 variables, etc.) all separated by commas.

---

<div class="post-metadata">

**Author:** ![valeriek](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/valeriek/32/851_2.png) [@valeriek](https://cl.desmos.com/u/valeriek)\
**Post date:** [November 20, 2021, 5:03pm UTC](https://cl.desmos.com/t/parsing-equation-with-different-input-variables/3834/6 "2021-11-20T17:03:44Z")

</div>

Thanks for your quick reply, Elayna. Yes, this would work, if P and V were different variables. But in this case there is only one variable and it is PV.

Is that possible to do?

If not, it’s okay. My work-around is to check all the possible latex answers. Tedious, but it works.

---

<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:** [November 20, 2021, 5:10pm UTC](https://cl.desmos.com/t/parsing-equation-with-different-input-variables/3834/7 "2021-11-20T17:10:02Z")

</div>

You can just treat them as though they’re different variables, and evaluate one of them as the desired entry and the other as 1. It’s two characters, so desmos won’t treat them as a single variable.

```auto
check1 = simpleFunction(right,"P", "V").evaluateAt(7215.74283,1) > 9990 and simpleFunction(right,"P", "V").evaluateAt(7215.74283,1) < 10010

```
