When I used Desmos Activity Builder previously (last year), I could label the function with its equation when the students used sliders to apply transformations. Now my label that previously appeared on the graph is labeled “undefined” and I do not know enough about the code to fix it. It no longer appears on the graph.
Here is what previously worked: ‘y=a_{n}b_{n}^(x-h_{n})+k_{n}’
This should make the exponential equation appear on the graph where the a, b, h, and k values can be adjusted with sliders on the graph. My slider values appear and the sliders function as they should to transform the graph.
Thank you for your help!
I had to do a few other things to make it appear like I wanted, but it seems to work pretty well now.
I have an additional question:
I want the equation to read (x+h) when h <0. How could I write the code for ${h_{n}} to appear positive when the slider reads -h_n ?
I was able to have the equation appear as “b^(x-h)” when h>0 and appear as "b^(x) when h=0. I just cannot make it appear as b^(x+h)
Unfortunately, you can’t do operations inside the ${}. So you would need another variable with the value -h_{n}, say a_{n}. Then you would do ${a_{n}} and it would essentially be -h_{n}.
You can also define your label in CL instead of in the graph, without needing conditionals. Your point needs to have a name in the graph (e.g. p_{label}). You’d also need to reference the values needed from the graph, which I’d define separately first as variables, but could be explicitly coded into the pointLabel() to reduce the number of lines of code.
For example:
a = this.number(`a`)
b = this.number(`b`)
h = this.number(`h`)
k = this.number(`k`)
## note curly braces aren't needed here, but would be in latex
pointLabel("p_label"):
formatLatex(`y=${a}_{n}${b}_{n}^(x-${h}_{n})+${k}_{n}`)
formatLatex() will remove products or addends of 0, coefficients or divisors of 1, and subtraction of a negative to addition.
The name of the point in the graph you want to place the label on. There are a few places where the curly braces are not used for the subscript. This is one of them.
Another counterintuitive place is with simpleFunction(), where the latex for the expression needs to use curly braces, but the definition of the variables does not. Generally this wouldn’t be noticed since most people use single letter variables. For example:
There are a few places where LaTeX does things a certain way that were less desirable, but we have no control over that. Rather than going with their syntax, the platform has opted for the more desirable simplified forms where possible. I think too the variable arguments in simpleFunction() can be strings rather than latex (similar to the sink argument).