Checking math input with radicals and pi

I am trying to create an activity for evaluating trig ratios with the unit circle. I want students to type in an answer like sqrt(3)/2 with a math input and have them see if they have the correct answer. I would also like them to be able to get the correct answer for inverse trig ratios where they would use a math type to get pi in their answer.

I have attached where I have made it to with the activity, but the only way I could get it to work is having students type in the decimal approximation. My programming skills are minimal and I am just trying to work through it with examples I have found on the internet to mimic. Any help would be appreciated!

If you’re comparing non-terminating decimals, you’ll need to round student input if they put it in radical form or check that it falls between to values. If you want radical form and not the decimal, you can use countNumberUsage.
In trig1:

check= this.numericValue<0.867 and 
           this.numericValue>0.865 and
           countNumberUsage(this.latex,3)=1 and
correct: check

In your note, replace trig1.numericValue=0.866 with:

1 Like

Thank you. I got that question to work. Here is my thinking on how to use that pattern, but am having trouble getting it to continue. I’m guessing I am not understanding the countNumberUsage.

By replacing the trig1.script.check into the spot where trig1.numericValue=0.866 I should only need to worry about adjusting the math input for each question.

For an answer of sqrt(2)/2 I came up with this:
check= this.numericValue<0.708 and
this.numericValue>0.706 and
countNumberUsage(this.latex,2)=1 and

correct: check

For an answer of -sqrt(3)/3 I came up with:
check= this.numericValue<-0.576 and
this.numericValue>-0.578 and
countNumberUsage(this.latex,3)=1 and

correct: check

I was thinking that the first countNumberUsage was the numerator inside a radical and the second countNumberUsage was the denominator, but that doesn’t seem to work.

countNumberUsage checks the latex for how many times that number is used, so for sqrt{2}/2:


You were checking if 2 was used once, and then again if it was used once, which was false.

If you don’t specify a number, it counts how many numbers are used, so for 2x+0.5
countNumberUsage(this.latex) would output 2


Thanks! That makes sense and fixed the problem. Hopefully last question:

What about entering a solution of an angle in the unit circle: for example 2pi/3

I could use the countNumberUsage for 2 and for 3, but pi doesn’t work as a number. Is there a countWordUsage type of function?

No you can’t check for pi, but if you’re also checking the numericValue range it shouldn’t matter.

1 Like

I was thinking I would have to account for pi in the solution, but it doesn’t matter. You only have to account for the countNumberUsage! Daniel, I really appreciate the help. The link at the top should have the code in it for others to see.

1 Like

Hi Daniel- So I tried using Jared’s code and your fixes to help with an assignment of my own where students will occasionally need to input radical answers, only on slides 3 and 5. I feel like everything in my coding is correct, but there must be some issue because on slides 3 & 5, when I input the solutions of 88sqrt3 and 300sqrt3 (respectively), it is still saying wrong answer… maybe I am just making some basic mistake or missing something else that you’ve already said above, but any insight you could provide would be most helpful!
Here is my assignment:

Ah. It’s your countNumberUsage. The parameter in it doesn’t count digits, it counts numbers. So, this change on slide 3 will fix it:


That did it!! Thanks so much for the quick reply!


Hello. I am trying to use these notes to check answers for log equations. This is how far I have gotten. I can’t seem to figure out how to get a “correct” message when students enter the correct expression log_5(48) in screen 2.

Please help? What am I doing wrong?

It is a problem with the countNumberUsage. You need to say which number you want to check for, and then how many times it shows up. Try this:

check= this.numericValue<2.406 and
this.numericValue>2.404 and
countNumberUsage(this.latex,5)=1 and

correct: check