# Can I use the abs function to test for correctness?

I’d like to have students calculate the slope in parts (change in y and then change in x) and check correctness along the way. The challenge is the direction matters.

What is wrong with this:
correct= abs(this.numericValue) =27

The abs command isn’t known to CL directly, so you would have to evaluate it using either

numericValue(\left| \${this.numericValue} \right|)


or

simpleFunction(\left|x\right|).evaluateAt(this.numericValue)


For a simple case like this, you might even just prefer:

correct = this.numericValue=27 or this.numericValue=-27


I might be missing something but if you say direction matters, why are you running it through the abs function?

I was struggling with the “or” function. That seems the easiest in this case.

By direction, I just mean when calculating slope you need to find the change in y and the change in x in the same direction.

Thank you so much for your prompt response.

Just note that when using OR and AND each part of the statement should be able to stand alone.

Yep, which is why I’m a bit confused as to why you’re leveraging the absolute value rather than the value itself. If the gradient is 27 then an answer of -27 is surely wrong (because it’s a different direction) but would be marked correct in this instance.

Appreciate this is drifting away from the original problem, but just wanted to get my head fully around what you’re hoping to achieve.

Well, I’m allowing that students could do both calculations “backwards” and still get the correct slope. Delta_y=-27 and delta_x =+9 results in the same slope/rate of change as delta_y=27 and delta_x=-9

Love this conversation.

Oh I see, the 27 is an intermediary value so the sign doesn’t matter, but the final answer will be sign-dependent - that makes sense now