E notation computation error

Something’s not working the way it seems like it should.

When I create a note with the code:
pval = numericValue("\cos(\pi/4) - \sin(\pi/4)")
x = numericValue("{pval}*2") content: "x = cos(pi/4) - sin(pi/4): {pval}

x*2 = ${x} "

I saw that the note displays:
x = cos(pi/4) - sin(pi/4): 1.1102230246251565e-16

x*2 = -28.982100926624597

But I expected the value of x*2 would be close to 0.

Here’s the link to the page, dashboard, or activity: Desmos Computation error • Activity Builder by Desmos

My guess is that the issue here is in the interpretation of the E notation. Desmos is thinking the e is just 2.71… and interpreting the expression in that way as 1.11*2.71-16 etc.

Thanks for the help.

I wouldn’t consider this an error in interpretation. NumericValue is performing the correct computation based on the string that you’re providing via interpolation. If you want a more accurate evaluation you can use another method like simpleFunction. Theres more detail here: Possible bug with evaluating using fractions in equation - #2 by Jay

That makes sense. I figured it had to do with the string conversion here, but I wasn’t sure how else to do the computation. I see that evaluateAt is the way to go. Thanks for the help!