Evaluating and comparing expression that has pi in it

Hi guys!

I am obsessed with making activities with interaction. I am doing activities that involve working with pi, and it’s a nightmare because when comparing you never know how many digits desmos will use.

	when input2.numericValue = 3.14159 true 
    otherwise false

I would like this to work no matter how many digits the students writes after 3.14. Let’s say when the error is less than 0.01 it would be correct.
This could easily be done in any programming language but in Desmos I find it difficult. Any ideas?

Thank you so much for your time,

Roger Borrell

Would something like this work for you?

pi = numericValue("\\pi")

	when input.numericValue = pi true 
    otherwise false

How about…

correct: numericValue("\\abs(${input2.numericValue}-\\pi)")<=0.01

(I don’t think you need to use a ‘when-otherwise’ conditional. An inequality or equation will evaluate as true or false)

1 Like

Thank you, tank you, thank you!

[cwinske] You introduce me to the using pi inside the code. I did not know this was possible

[Daniel_Grubbs] That’s exactly what I wanted to achieve. And you did it in such an elegant way that I am so amazed! It does work.

I have learnt so much from it.

Where can I get documentation of it? Are you actually using the same functions of the desmos calculator in the code? Are actually, the sinks, variables of the Desmos calculator?

Thank you!

I answer my self on this last questions:

  • The numericValue functions just converts a Latex expression to a Math evaluable expression. Inside of those Latex expression you can use a variable as long as you put it in the form ${variable}.

I am unsure if Desmos provides Latex documentation. I was unable to find anything.


I usually handle these type of correctness with using a correctness checker built-in to the graph component. Check if c_1={pi - a < .01: 1,0}

Here “a” would be the student input and the level of precision. Then the value c_1 tells me it is correct if 1, false if 0… which comes in handy if you ever create correctness checkers for multiple parameters.

1 Like

Totally spaced on using the graph, PanettaMath. Usually, the easiest way to deal with any calculations if possible. Random numbers are the only thing that seem less complicated in CL.

Roger, there’s not really any latex documentation for Desmos specifically. However, if you know how to do it in a graph, do that and then copy paste it into the CL. It’ll convert it for you. You can just google for a specific LaTex notation. Just note that when a single backslash is used for LaTex (and in Desmos graph), CL requires a double backslash.

You should use absolute value of pi-a though. If a student entered 4 or even 10, it would say correct since pi - 4 is a negative and therefore <0.01.