I am new to CL and committed to learning it, but I was hoping for a quick answer to get my lesson for next week to the next level in DESMOS.
I want students to write a linear equation in standard form ax+by = c from a word problem and then I want DESMOS to graph it. I can’t seem to make this work using f(x). How do you graph when it is not in function format? For instance if a student inputs into my f(x). called moneyeq. How would I set up the graph and its script?
function(“f”):simpleFunction(moneyeq.latex). doesn’t work when students type in 2x+y = 4
simpleFunction takes an expression (the right side of a linear function). I think the function sink always does in terms of x, so having y would confuse it.
Since they’re writing it from a word problem, there should be a correct answer I assume. In which case, you could check that their answer is correct.
#parseEquation().lhs gets the expression for the left hand side of the equation, and simpleFunction(___, “x”,“y”) specifies a function with variables x and y. So I’m making a function from the left side of student input, then evaluating at two solutions of 2x+y=4 and seeing if the left side does in fact equal 4. If correct, check = 1. If not, check =0.
eqLHS=simpleFunction(parseEquation(moneyeq.latex).lhs,“x”,“y”)
check=when eqLHS.evaluateAt(0,4)=4 and eqLHS.evaluateAt(-2,0)=4 1
otherwise 0
In the graph CL: number(“k”): componentName.script.exp1
In the graph: 2x+y=4 {k=1} #this will graph only if k=1
As an alternative, you can use xyLine to parse the input. Then, you can build a simple function from the slope and intercept, and pass that down to the graph for plotting. xyLine is defined for any linear form, and will be undefined if students include a non-linear term.
Graph Expression List: y=f(x)
Graph CL: l = xyLine(moneyeq.latex) function("f"): simpleFunction("${l.slope}*x+${l.yIntercept}")
Input CL: errorMessage: when isDefined(xyLine(this.latex)) "" otherwise "Enter a linear equation"
Again, that will plot the line regardless of form. If you need students to be practicing standard form specifically, I’d recommend setting up a table and asking them to give values for a and b separately.