in reply to Re: How to get better exponentiation? (undefined) in thread How to get better exponentiation?
German Wikipedia states that it's disputed, if the cube root of a negative real number was defined
I finally got around to taking a look at the C89, C99 and C11 standards.
There's no mention of "cbrt" in C89, but in C99 and C11 it's quite acceptable for cbrt/cbrtf/cbrtl to take a negative argument.
However, if pow/powf/powl are given a first argument that is negative && the second argument has a non-integer value, then a "domain error" occurs.
Cheers, Rob
Re^3: How to get better exponentiation? (undefined)
by LanX (Saint) on Jan 24, 2022 at 13:18 UTC
|
Yes, thanks.
But I was talking about mathematical definitions and these are CS standards.
For instance: pure math has no big notion of floating point numbers.
Personally I'm fine with allowing root($x,$o) with $x<0 and $o odd integer in a computer.
But I could imagine reasons in the realm of mathematical modeling of functions to consider them undefined.
> the second argument has a non-integer value
I'd say because there is no way to express 1/$o loss free as binary floating point number ('$o odd integer')
update
see also https://en.wikipedia.org/wiki/Cube_root#Complex_numbers
With this definition, the principal cube root of a negative number is a complex number, and for instance 3√−8 will not be −2, but rather 1 + i√3.
| [reply] [d/l] [select] |
|
see also https://en.wikipedia.org/wiki/Cube_root#Complex_numbers
I don't think they are intending to cast aspersions on the validity of taking a cube root of a -ve Real number.
They even state "For real numbers, we can define a unique cube root of all real numbers.".
They follow that immediately with "If this definition is used, the cube root of a negative number is a negative number."
That wording is a bit odd, but I don't think they're suggesting that there's some alternative stance to take wrt cube roots of -ve Real numbers in the *Real* field.
Rather, I think they're acknowledging that this definition is deficient in the Complex field (even for -ve Real numbers in the Complex field) because, in the *Complex* field, the relationship between a -ve Real and its cube root is no longer one-to-one. It's one-to-three.
Cheers, Rob
| [reply] |
|