I want students to enter the ranges of the inverse trigonometric functions, but wonder how to code to allow for equivalency.
I think I can code it to look for:
-pi/2<=theta<=pi/2, but what about equivalent inequalities like -(pi/2)<=theta<=pi/2 or -1/2pi<=theta<=1/2pi. I don’t want to have to look for all possibilities.
It would probably be good at least to give the students a warning if the question requests (as is common) that they give an answer in the range [ -pi/2, pi/2 ] and if their submitted answer strays outside that range.
That said, a general way to check that a submitted answer gives the right output would simply be to re-apply the trig function that was inverted, and see whether the desired answer comes out.
Here’s an example, asking for arcsin(\sqrt{3}/2), and containing this CL:
answerHasBeenSubmitted = input.submitted
inputVal = input.numericValue
isInRange = when not(answerHasBeenSubmitted) "No submission yet"
otherwise
when not( numericValue(`\abs(${inputVal})`) > numericValue(`\pi/2`) ) "✅"
otherwise "❌"
tol = 0.000001
givesCorrectSin = when not(answerHasBeenSubmitted) "No submission yet"
otherwise
when numericValue(`\abs(\sin(${inputVal}) - \sqrt{3}/2)`) < tol "✅"
otherwise "❌"
Submitted answers pi/3 and 2pi/3 will both give a for the CL variable givesCorrectSin, but only pi/3 will give a
for the CL variable isInRange