Understanding abs()

My HP-71 does, though it is not exactly current. And since it was one of the first to implement IEEE754, it must be part of the standard.

RayLivingston:
The meaning of "-x" is 100% unambiguous, standard mathematical notation, and should be crystal clear to anyone who has taken the first day of high-school Algebra. It is 100% equivalent to writing "x * -1".

Regards,
Ray L.

Hi Ray,

Yeah well that's not the impression i got after reading through this thread. For you and i perhaps that is true, but certainly not for everyone, hence my post which was designed specifically to target the sign problem that appeared elsewhere where it seemed to be a little uncertain if -x meant -5 or it meant -(-5). You'll have to look back and read carefully to see this.

In other words, rather than have a sign that could be part of the value itself or a multiplier of the value itself, we have an explicit representation when we use "-1" times the variable 'x'. That makes it a little more clear that we want to change the value of x no matter what it is. So it makes it slightly less ambiguous to those who see the original form "-x" as ambiguous in the first place.

Delta_G:
If you call abs(-5) and I talk about abs(x) how could x be anything other than -5? So how could -x be anything other than 5? How in the world do you separate the - from the 5 and get that x is 5?

I don't think this is a matter of ambiguous documentation or ambiguous math. This is simply a case of someone not thinking it all the way through and seeing a negative sign and jumping to a conclusion without thinking about what it means. If you want to try to fix every place in programming where that can be the case you're going to have a long road ahead of you. The problem here is with the reader, not the documentation.

Hello there,

Pardon me, but i can assure you that you havent thought this through either :slight_smile:

Yes, there is no real ambiguity in the math or in the program code, but that is from your point of view. To someone who is not as familiar with this there may still be an ambiguity. In other words, it is not JUST how YOU see it, it is how other people see it, more so because they see an ambiguity which we seek to clear up. In trying to clear that up, we can come up with different approaches in order to reach that part of them that does not understand what is really being said.

A totally color blind person is shown two party balloons, one red and one blue. To most people they see one red and one blue so there is no ambiguity. However, to the color blind person they cant tell the difference, they both look the same. So how do we resolve this problem? One way is to stick labels on the two balloons, one that reads, "RED", and the other that reads, "BLUE". Now when the color blind person looks at them there is no more ambiguity, they know which is which. So by providing a little more information we've helped the person to be able to distinguish between the red and blue balloons, and note this is solely for the benefit of THEM not US in most cases. That's the whole point, to help THEM because we dont need any help unless of course we are color blind too :slight_smile:

So the "-1" multiplier is for THEIR benefit, not OURS.

UKHeliBob:
No surprise that in both cases the answer is 123. It is exactly what I would expect, but I find the explanation that the function returns -x when x is negative less than helpful when what it actually returns is x.

It doesn't return x when x is -123.

if it returned x when x is -123, then it would return -123, because x is -123. Instead of returning x (ie: -123), it returns +123.

I think I see what you are getting at, but what you are reading is not what is written there.

THIS is what you think the docs say:

returns x if x >=0, returns -x if -x is less than 0

or to put it another way

"x is 123, if you pass negative x, you get negative x"

That's not the way the docs are written. You are not passing -x into the function - what you are passing is simply x, which may be a negative number. That's the way x is defined. When you go abs(-123), x is -123, not 123.

It is not ambiguous, you re just confused.

A non-deterministic mathematician says to another, "You know, 2 + 2 = 5 for large values of 2." The other ndm replies. "How large is large?" "I dunno!", exclaims the first. "Wanna go in on a grant with me to find out?"

When language and logic trip you up:

:slight_smile: Ok I should have stated that in this particular example, you (Delta_G, not AWOL ... huh?) gave the correct answer in reply #3.

But your last reply used an arithmetic example, and applied that result to math in general. In particular you poised small-number arithmetic as a better example of math's certitude than was colorblind interpretation. Color vision deficiency can be defined using opponent theory, which is based on arithmetic where two plus two would not necessarily be four, but rather is a range based on a statistical model.

Your third paragraph railed against dumbing down math for easy consumption. So my (light-hearted or smug & glib - your choice), response was meant to suggest that math is much more complex than simple arithmetic. I felt that your reply could give a limited view of math, and wanted to correct that as succinctly as possible. No disrespect was intended.

Delta_G:
From a strictly mathematical standpoint, square then square root would give two answers, one positive and one negative.

No, it would not. The square root (on positive real numbers) is defined as the positive number whose square gives the argument.
You confuse that with the solution of quadratic equation, which are ...+sqrt(...) and ...-sqrt(...). If you where right, you wouldn't need the +- in the pq formula. Most math teacher are incapable of explaining that correctly, though.

Regarding the issue, #32 by PaulMurrayCbr nailed it.

ElCaron:
No, it would not. The square root (on positive real numbers) is defined as the positive number whose square gives the argument.
You confuse that with the solution of quadratic equation, which are ...+sqrt(...) and ...-sqrt(...). If you where right, you wouldn't need the +- in the pq formula. Most math teacher are incapable of explaining that correctly, though.

Regarding the issue, #32 by PaulMurrayCbr nailed it.

Really?

I thought the definition of square root was the number, which when multiplied by itself, resulted in the argument. Perhaps you mean the result of the sqrt() function.

Delta_G:
Literature is open to interpretation. You may see it differently than I do. Politics is open to interpretation, you may see it differently than I do. Even hardcore science like chemistry or physics is often open to interpretation and we may have differing points of view.

Mathematics is not like that. That's what I love so much about math. There's only one opinion. There's only one answer that's right. You and I cannot have different math or one of us is outright wrong. We can't have different points of view on math. Even if we speak completely different languages we have the same math. Aliens from another galaxy come to Earth and the one thing we can be sure we both understand the same is math. You can't say, well to me 2 + 2 is 5 it's all about point of view. There's only one way to interpret mathematics. There's no room for opinion in mathematics. We're not talking about a color blind person seeing balloons. Yes I see your point with balloons. But this isn't balloons. And there's no such thing as math blindness where to one person they see 2 apples and 2 more apples and see 5 apples. The negative of a negative number is a positive number. Always. And if your interpretation or opinion differs with that then you're wrong. And if you don't know it yet then you need to be taught. But there is no other point of view on math.

And trying to change the math so that the ignorant can still see it only serves to perpetuate the ignorance. What you need to do is not to dumb it down. That leads to dumber people. What you need to do is educate those who don't get it. This isn't religion or politics or literature or music. It's math. It's not open to interpretation or opinion or point of view or language or anything else.

Hello again,

He he, this turns into a funny discussion.

We are talking about teaching someone else to understand something that they dont yet understand. There are various ways to do this. The point is if they learn it, then you probably taught it correctly.
In trying to do that, we might come up with several ways, some will work better with some and others with others. So knocking one method over another without evaluating the outcome is worthless.

Language may be open to interpretation but so is math, that's why we have geometry. And making up simple analogies that are known to be wrong does not prove a single thing, sorry to say. Let me give you a few more examples:

Apples are not the same as oranges, therefore i am right and you are wrong.
The grass is greener on the other side, therefore i am right and you are wrong.
People walk faster in the rain, therefore i am right and you are wrong.

See how these arbitrary arguments dont prove anything, they just make a statement that appears to show some analogy. People can be right or wrong, but they are right or wrong for the actual point in question, not some arbitrary input. You can tell because everything you said about my view can be said about your view. We were talking partly about math, so it seems like 2+2=5 shows how math cant be wrong, but it wasnt really math anyway it was the interpretation of that math. The user may not have been interpreting the expression correctly, and we sought to help clear that up. No interpretation? Then what is the correct answer to:
1+1=?
Is it "2" or is it "10" ?

So what you are arguing about math may be completely true and accurate to the highest standard, 2+2 doesnt usually equal 5, but it is not the point. We are talking about teaching another person or persons to understand a concept that they dont yet understand. If we keep stating the same thing over and over again and they still dont get it, we try something else. That's what i did an i am 100 percent sure it was the right thing to do, with no question, and there is nothing under the sun that can change my mind unless it comes from a reasonable argument from someone who understands completely both points of view.

Let me put it another way too. My view includes your view, so my view is your view plus some extra, up to the point where you disagree with my extra view.

The square root of a number is also open to interpretation, again, due to the geometry of the situation. Only in pure math may we make a statement like yours. Life isnt about pure math, it's about pure math and it's interpretation, or to put it another way, it's application.

No math blindness? So you are saying that everyone on this earth understand math completely and accurately? I dont think so.
If they did we would not be having this discussion :slight_smile:

MrAl,
So how low does one have to stoop to support the ignorant and/or uneducated?
Should there be a remedial math lesson included in the description/documentation of every single math type function in the language or its libraries in case the reader is ignorant as to mathematics?
To me that is just plain silly.

Some of this discussion is starting to remind me of "Verizon math...."

Which is a great example of people not understanding some pretty simple basic math and yet given that the verizon people also believe in their correctness, it seems to also demonstrate the Dunning-Kruger effect.

--- bill

Delta_G:
If abs(x) is abs(-5) so x is -5. So -x is 5

If you think that -x is -5 then you must be thinking that x is 5

Perhaps for those that don't understand elementary school math, adding back the omitted step might help them.
The macro actually works this way:

abs(-5) is -(-5) which is 5

IMO, I think on the Arduion abs() web page it should use a textual description for the return value instead of simply describing how the macro was implemented.

For example some thing like this:

Returns: the non-negative value of x without regard to its sign

--- bill

Unbelievable this has run to 45 replies.I think I'll watch this thread so I can do reply #100.

UKHeliBob:
That is, of course, true.

Bad English on my part

This, I believe is the crux of the difficulty. However the fault is not yours Bob, it is English's.

In English we have two words, "negate" and "negative", and they seem be colsely related to each other. Negate means to change the sign, while negative means less that zero.

Negative can also mean "No":
Do you have a visual sighting of the bank robber? Negative.

Negate can also mean to counteract something else.
The snake antidote negated the effect of the venom.

Ain't English wunnerful? My definitions were in math terms. Negative can also mean "bad mood" or contrarian. NE gate can be the airport boarding portal in the north east of the terminal. Is there any other language that is so dependent on context, that nearly anything can be inferred from any utterance? I believe that English was constructed as an ideal language for obfuscation.

So essentially one must negate the absolute value of a negative in order to to return to the identity.

PaulMurrayCbr:
Unbelievable this has run to 45 replies.I think I'll watch this thread so I can do reply #100.

I am also surprised by number of replies. :o

So essentially one must negate the absolute value of a negative in order to to return to the identity.

One must negate the negative to obtain positive, isn't it? (English is not my mother tongue.)

The best advice that I have found is

You've got to accentuate the positive
Eliminate the negative
Latch on to the affirmative
Don't mess with Mister In-Between

bperrybap:
MrAl,
So how low does one have to stoop to support the ignorant and/or uneducated?
Should there be a remedial math lesson included in the description/documentation of every single math type function in the language or its libraries in case the reader is ignorant as to mathematics?
To me that is just plain silly.

Some of this discussion is starting to remind me of "Verizon math...."
https://www.youtube.com/watch?v=MShv_74FNWU

Which is a great example of people not understanding some pretty simple basic math and yet given that the verizon people also believe in their correctness, it seems to also demonstrate the Dunning-Kruger effect.

--- bill

Hello there,

How about 50 or more posts, is that low enough yet? (he he) :slight_smile:

What you just did was basically declared yourself too good to help anyone else with a problem, and that sounds strange because this is a discussion forum where people come to ask questions and people come to help answer those questions.

Not only that, you declared that helping someone too much is stooping too low, then you came up with a single solution, then put your own solution down by calling it silly! My advice then is dont come up with silly solutions :slight_smile:

I've been helping people with problems of all kinds since i was a little kid. I used to help other kids fix their bikes for example. I dont see that stopping anytime soon and i dont feel like i am stooping too low to do it.

Feynman noted that different people internalize concepts differently. This means that different techniques will help people that dont understand the mainstream ways. I dont mind trying a few different approaches myself, if i can think some up that might help. I feel it's better to try than to kick them out of the room.

So i just cant help but feel that stating that someone is sinking too low to help someone that is having a problem understanding a concept is a terrible way to view other human beings and their problems. Of course it's always up to you how you want to think about this, there's no law that forces us either way.

MrAl,
You completely misunderstood my comment.
I never said that I wouldn't help anyone nor did I say that the ignorant or uneducated shouldn't be helped or educated.
I was stating that descriptions/documentation for math type functions should not also have to include a math lesson.

In other words my belief is that when documenting math type functions, it is perfectly acceptable that the documentation assume that the reader has a basic level of math comprehension.
When people don't have that understanding, it is perfectly reasonable that they can reach out to forums like this one and get assistance and even I will offer them help.

For this thread, I don't believe that it was the OP that triggered the start of the odd and twisted discussion.
Things appeared to go south from a lack of understanding that -(x) is the way make a negative number positive.

--- bill