# Thread: My grandpa told me a good way to get the absolute value of a number was to...

1. ## My grandpa told me a good way to get the absolute value of a number was to...

So you have some float, a. My grandpappy says that a good way of getting the absolute value is to square the number then square root the result.

I facepalmed so hard.

Did we not just flip sign bits back then or what? Mind you, this was all done in Basic too which I'm not sure what that is. 2. It sounds like your grandpa is good at trolling you  3. This technique is used, among other things, to find the "average" value of a waveform that has data both in the positive and negative regions. It is the R and S in RMS.

For instance, the average of a perfect sine wave is zero (the positive area == the negative area, which when combined, result in zero).

So by squaring the points of a sine wave, you make all negative points positive. Then you find the mean of those squares. Then you take the square root to arrive at the RMS value. 4. Originally Posted by MutantJohn Did we not just flip sign bits back then or what?
Not meaning to be pedantic, but this wrong... Square rooting doesn't provide a positive number, it returns an unsigned number (one that is neither positive nor negative). 5. Not meaning to be pedantic, but this wrong... Square rooting doesn't provide a positive number, it returns an unsigned number (one that is neither positive nor negative).
O_o

Actually, the "square rooting" of a nonnegative real produces both a positive value and a negative value.

Soma 6. Originally Posted by phantomotap Actually, the "square rooting" of a nonnegative real produces both a positive value and a negative value.
To add to this, the mathematical notation for the result (y) of the square root of x is y=−√x and y=√x. It's not -y and y. The idea that the square root returns a unsigned number and then we add both signs to each result is incorrect. The only number which isn't either positive or negative is 0. 7. The square root function (by the mathematical definition) returns a single value, the principal square root, always positive number. The negative of that value also solves the equation x^2 = y. This is a coincidental, because the root in this case is 2 (an even number), the "negative root" works: but if the root is odd, it does not work.

For example, pow(8, 1/3) = 2, but (-2)*(-2)*(-2) = -8. 8. The square root function (by the mathematical definition) returns a single value, the principal square root, always positive number. The negative of that value also solves the equation x^2 = y. This is a coincidental, because the root in this case is 2 (an even number), the "negative root" works: but if the root is odd, it does not work.

For example, pow(8, 1/3) = 2, but (-2)*(-2)*(-2) = -8.
O_o

Do you realize that you used a specific flavor of square root (I'm speaking of the result; I'm not speaking of the operation.[/Edit]) to draw a conclusion about the value provided by the square root operation in general?

Do you realize that you used an example which isn't a square root to draw a conclusion about the value provided by the square root operation in general?

I'm not sure what you are trying to say, but you have failed.

The word "principal" in "principal square root" is important in context precisely because it is the principal square root which is the nonnegative. In other words, the square root function returns two values the nonnegative of which we've chosen to distinguish in materials as the "principal".

As far as it goes, your example of a cubed root is correct. However, you are the first person to reference cubed roots. As is obvious, a cubed root is not a square root. The cubed root example simply shows nothing about the principal square root or square roots in general.

The square root operation does not return a single value. The square root operations returns two values. You can speak specifically about the principal square root, but the principal square root is not an operation. The principal square root is the nonnegative result of applying the square root operation to a nonnegative real.

Also to be absolutely clear, there is nothing whatsoever coincidental about these operations, the results, or the language used to describe those results.

We described the operation. Part of the description of the square root operation is the results of that operation. The language "principal square root" is similarly defined to allow people communicating about mathematics to speak specifically about one of those results.

Similarly, the "negative root" works, and the result is not any way coincidental.

Consider:

Code:
```pow(16, 1/2) = 4 and -4
4 * 4 =  16
-4 * -4 =  16```
That is not coincidence.

That is fact.

This fact arises because the very definition of roots and multiplication.
[/Edit]

Soma 9. Originally Posted by Yarin Not meaning to be pedantic, but this wrong... Square rooting doesn't provide a positive number, it returns an unsigned number (one that is neither positive nor negative).
Then this is even more reason not to use it!

The only way to give the roots any significance is to assign a sign (for both negative and positive values) which requires an unsigned to int conversion which creates the possibility for rounding errors.

*Sigh* 10. Originally Posted by MutantJohn
Then this is even more reason not to use it!

The only way to give the roots any significance is to assign a sign (for both negative and positive values) which requires an unsigned to int conversion which creates the possibility for rounding errors.
I think you're confusing Yarin's mathematical assertion with a particular implementation in some programming language. Yarin's use of "unsigned" here just means "has no sign", which was explained as "neither positive nor negative", not "unsigned int".

Anyway, Yarin's claim is new to me: I learnt it the way phantomotap and Mario F. stated in posts #5 and #6. The claim sounds wrong since I understand a real number greater than zero to be positive, not "unsigned" just because it is a square root. 11. Originally Posted by MutantJohn Then this is even more reason not to use it!

The only way to give the roots any significance is to assign a sign (for both negative and positive values) which requires an unsigned to int conversion which creates the possibility for rounding errors.

*Sigh*
Rounding is good. Roots aren't meant to be square. Haven't you ever seen a tree? Sounds like your Grandpa knows what's going on! 12. Originally Posted by laserlight Yarin's use of "unsigned" here just means "has no sign", which was explained as "neither positive nor negative", not "unsigned int"
It would even be best to just drop the word "unsigned". It has no meaning in mathematics. It is strictly a computational term.

In computing unsigned refers to a value that can be either positive or negative. In mathematics, 0 is neither positive or negative. While the square root of a positive number returns both a positive and a negative result. 13. Originally Posted by laserlight Yarin's use of "unsigned" here just means "has no sign", which was explained as "neither positive nor negative", not "unsigned int".
Exactly. Originally Posted by Mario F. It has no meaning in mathematics.
An ironic thing to say considering Wiki has an article entitled "Sign (mathematics)". Originally Posted by Mario F. It would even be best to just drop the word "unsigned".
Probably true nonetheless. Originally Posted by Mario F. While the square root of a positive number returns both a positive and a negative result. Originally Posted by laserlight The claim sounds wrong since I understand a real number greater than zero to be positive, not "unsigned" just because it is a square root.
Indeed, the standard definition of a square root is
Code:
`{x, -x}`
, because there's no way of knowing whether or not the source was negative or positive (tis a give-in, everyone knows this).
However, I prefer to think of "x" and "+x" as "unsigned number" and "positively signed number" rather than the same things, specifically in the context of absolute numbers as presented by the OP, because when you say "+x" it's understood that you are considering a number that is positive as opposed to being negative, but a singular return value of a square root (again, in the context the OP set) cannot be known to be positive or negative, yet it's still clearly a number, hence "unsigned". 14. Originally Posted by Yarin An ironic thing to say considering Wiki has an article entitled "Sign (mathematics)".
And yet makes no mention of unsigned numbers...

Indeed, the standard definition of a square root is {x, -x}, because there's no way of knowing whether or not the source was negative or positive (tis a give-in, everyone knows this).
What do you mean we don't know the source? The square root of a negative number is a complex number and doesn't follow the same formal definition of the square root of a positive number.

However, I prefer to think of "x" and "+x" as "unsigned number" and "positively signed number" rather than the same things, specifically in the context of absolute numbers as presented by the OP, because when you say "+x" it's understood that you are considering a number that is positive as opposed to being negative, but a singular return value of a square root (again, in the context the OP set) cannot be known to be positive or negative, yet it's still clearly a number, hence "unsigned".
You are looking at this from a computing perspective. The OP grandfather was almost certainly speaking about mathematics. 15. Originally Posted by Yarin
However, I prefer to think of "x" and "+x" as "unsigned number" and "positively signed number" rather than the same things, specifically in the context of absolute numbers as presented by the OP, because when you say "+x" it's understood that you are considering a number that is positive as opposed to being negative, but a singular return value of a square root (again, in the context the OP set) cannot be known to be positive or negative, yet it's still clearly a number, hence "unsigned".
The context that MutantJohn set is about "absolute value". Therefore, considering the positive and negative square roots of the square of the original (positive real) number, we should obviously choose the positive. There is no need for an additional notion of an "unsigned" number in this context. Popular pages Recent additions 