Parsing equation with different input variables

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

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!!

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

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

Of course!! Thank you so much, Daniel.

1 Like

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

when this.submitted and check1 “:white_check_mark:
when this.submitted and not(check1) “:x:
otherwise “”

initialLatex: 10000 =
correct: check1

disableEvaluation: true

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

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.

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.

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.

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