Error on expression evaluation

34 views
Skip to first unread message

Logan Lecas

unread,
Feb 24, 2025, 10:34:28 AMFeb 24
to desmos-api-discuss
I have code that should take in two points from a form and then add an expression to the screen to calculate the distance. However, it gives an error when trying to evaluate it, but the error is fixed if a user clicks onto the expression and moves the text cursor with the arrow keys or presses space.

Screenshot 2025-02-21 234517.pngScreenshot 2025-02-21 234548.png

Vincent Van doordrecht

unread,
Feb 24, 2025, 11:52:50 AMFeb 24
to desmos-api-discuss
Hi Logan,

It seems to me that your latex isn't properly formatted so that the calculator can understand it. I believe the following is happening: Desmos is parsing the distance function not as a function, but as a bunch of variables multiplied together and (original, second) as a point, not parameters of the function. Selecting the expression and moving the cursor, or modifying the expression makes Desmos normalize the latex. This causes it to realize distance is in fact a function . Can you try changing the calculator.setExpression line to use the following latex:
`o_{distance}=\operatorname{distance}(${original},${second}})`
Note how distance is replaced by \operatorname{distance}. This makes it clear to desmos that distance is a function.

Please let me know if this fixes it!

Sincerely,
Vincent van Doordrecht
Reply all
Reply to author
Forward
0 new messages