Checking trig value in CL

I’m trying to code a table, tt1, so that a checkmark in cell (1,3) is displayed if the sine of the angle measure (in degrees) in cell (1,2) equals sin(38°).

My activity is in degree mode. This is what I have coded in the CL of the table.


when isBlank(tt1.cellContent(1,2)) “”
when a = simpleFunction(\sin(${tt1.cellNumericValue(1,2)})).evaluateAt(0)
otherwise “:x:

But it only displays the checkmark if 38 is entered into cell (1,2), not if, say, 142 is entered into it. I am fairly new to CL coding in Desmos and am not sure what I am doing wrong.

I think you’re dealing with a rounding issue. You can check that the difference between sin(38) and sin(angle) is less than a small tolerance amount. See example here: trig example • Activity Builder by Desmos

Thank you so much! That worked perfectly. Do you have a simple explanation as to why that is needed (since sin(38) exactly equals, say, sin(142))? I’m sure it has to do with Desmos’s computational engine, so if it’s too complicated, no worries.

It’s because of the way they handle floating point arithmetic. So symbolically sine 38 and sine 142 are identical, but the way they are calculated and rounded, they are probably off by like 0.000000000001 or something.

It’s important to keep this technique in mind because it will always apply for non-terminating decimal approximations. Square roots, divisions, etc. I only use an exact equal condition if I know both values are integers or terminating decimals.

1 Like