Divide by 0 equals infinity

I have students enter in a rational function. They are then testing different values for x. I want the result to say Undefined if they enter a value now it says infinity or -infinity

Could you use a conditional to check if the result is infinity, and when it is, replace it with the word “undefined”? I’m not sure which type of component you are working with, but this works within a note component:

#get value entered by student into a math input box
in = input.numericValue

#computes the quotient 1/input. Modify n/d as needed 
answer = simpleFunction("n/d", "n", "d").evaluateAt(1, in)

#computes the value of infinity
infinity = simpleFunction("n/d", "n", "d").evaluateAt(1, 0)

#sets the content of this note box to undefined when the answer is infinity, or the numerical answer otherwise
content: 
when answer = infinity "undefined"
otherwise "${answer}"
1 Like

This is an Activity bug imo.

k/0 != infinity(though its functional limit may be) and it’s not at all clear to me why Desmos would report this to be so in an Activity when it(correctly) evaluates this to Undefined in the calculator itself.

Interesting.