how do I get Desmos's way of calcuating expressions?

29 views
Skip to first unread message

Yoav Haklai

unread,
Dec 12, 2024, 10:16:55 AM12/12/24
to desmos-api-discuss
so I'm making a game in a website (html, js) that teaches math functions and in it you can type math functions (only ones that have the format: y = ___).

Screenshot 2024-12-12 101323.png

I use the Desmos api to draw the functions on a graph in the background but I also create an array, one that has the length of the screen in pixels, in which the index is the X value of the pixel on the screen and the value of the list in that index is the Y value of the pixel on the screen.

in simpler words, I made a list that "IS" that function in a list, for every X on screen it gives you that function's Y.


Screenshot 2024-12-12 101447.png

the problem with that is that I use mathjs.parse() to calculate the Y value using the function and the X value, which is completely different from how Desmos calcualtes it.

Screenshot 2024-12-12 101546.png

for example if I type: "y = x3", Desmos draws it the same as "y = 3*x". but with my version it just doesn't work.

my solution so far was to meticulously go through each difference between mathjs and Desmos's calculation difference and change mine to fit Desmos's. but in this way I will just keep finding more problems with no end.

my question is, is there a way I can use Desmos's way of calcualting expressions? maybe a function that I can enter an X value and a math expression as inputs to and get a Y value as an output?
Reply all
Reply to author
Forward
0 new messages