Accepting a range of values

I know several people have asked about this, and there are several answers, I just can’t figure out how to apply them to my activity. (Because I don’t know enough about the CL coding, I just try to copy and paste things from other activities…)
I am having trouble accepting a range of values for the parts called question1b and question1d.
Here is where I’m at. Can someone suggest what I need to change (and what is wrong with what I have)?
https://teacher.desmos.com/activitybuilder/custom/6483760410e95cc9eaea4704

There are lots of ways. I’ve edited the slide to make it work. I also added in a check for the approximate ones that will make it come out incorrect if they put the answer in terms of pi. [Copy of] Unit 1 Day 1 Homework • Activity Builder by Desmos

Thanks so much for your help!

Hi Daniel, I am hoping you can help me with another issue I am having on this assignment.
We ask students to given an exact value (in terms of pi), but then they write the value in various ways like “\frac{1}{3}\pi” or “\frac{\pi}{3}” What suggestions do you have to accept equivalent expressions? I know I could code to accept if it is one or the other, but I think I would also want to accept things like “\frac{2}{6}\pi”, but not “\frac{4}{3}\pi-\pi” (I want is to be a number times pi).
Thanks
Amy

Sure - you can use patterns to do that. There might be a more elegant solution, but my idea is to set up a pattern for the possible forms, like pi, pi/n, n/pi, a/b * pi, etc. You then match their input against these patterns to see that the structure is correct and add that into the check to see if the value is correct.

That is super helpful. Thank you!

1 Like

OK, it still isn’t working. Students are entering 92/3*pi and it isn’t being accepted. Is it because desmos views this as an “expression” and not a “number”? It is slide 13 on this activity.

I think it was due to a slight rounding error - a difference in the way desmos calculates (92/3)pi and (92pi)/3. I changed the test for equality to testing that the absolute value of the difference is less than a small tolerance value.

Thanks again!
Any idea why those get rounded differently? I’m just trying to decide if I need to start doing this for all answers in terms of pi, or if I can narrow down which ones the error will occur on.
Amy

I don’t have a deep understanding of it, but it has to do with floating point data types and how the Desmos engine evaluates things. When you have integers, usually an equal sign is enough. But once you are dealing with irrationals, you are likely to run into these rounding errors. I should have thought about that in the original help I gave you. I tend to use the absolute difference method most of the time, unless I know for sure calculations will be limited to integers. I don’t know if you could predict which particular calculations ahead of time would give a rounding error.

That’s why it’s pretty handy to use both a structure check and a value check when looking for correctness. First check if the form is correct (i.e. is written in terms of pi) and then check if the numerical value is correct (within a certain tolerance level).

Thanks for the insight!