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.

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.

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?