| Summary: | Error taking Cube Root of Negative Number | ||
|---|---|---|---|
| Product: | LibreOffice | Reporter: | Mike Kaganski <mikekaganski> |
| Component: | Calc | Assignee: | supremearyal |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | barta, jbfaure |
| Priority: | medium | ||
| Version: | Inherited From OOo | ||
| Hardware: | Other | ||
| OS: | All | ||
| See Also: |
https://issues.apache.org/ooo/show_bug.cgi?id=37129 https://bugs.documentfoundation.org/show_bug.cgi?id=44076 https://bugs.documentfoundation.org/show_bug.cgi?id=148488 |
||
| Whiteboard: | target:4.5.0 | ||
| Crash report or crash signature: | Regression By: | ||
|
Description
Mike Kaganski
2013-09-12 21:41:31 UTC
set status to NEW because of confirmation in old OOo bug report cited in previous comment. Supreme Aryal committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=b0fdf6cf11ee46d46925e9cd9fa2768a1b49bb64 Compute n-th root of negative numbers where n is odd. (tdf#69293) It will be available in 4.5.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback. The definition of (-8)^(1/3) is not the cubic root of -8, it is exp((1/3)*ln(-8)) which is not defined as ln(-8) is not defined. Making a special evaluation of a^b when b = 1/n with n equals to an odd integer, produces inconsistency with the mathematical definition of a^b.
> And it's not correct to speculate that "(-8)^(1/3)=(-8)^(2/6)=((-8)^2))^(1/6)=64^(1/6)=2".
I disagree: this "speculation" proves that the exponentiation function with 1/n exponent, matches the n-root only for positive numbers. You can not accept the theorem a^(b*c) = (a^b)^c in case a > 0 and refuses it in case a < 0 if you accept this case.
Additionally : (-8)^(1/3) = (-8)^(2/6) = ((-8)^(1/6))^2 which is impossible because a negative number does not have n-root for n even.
So using exponentiation function with a negative base is inconsistent with commutativity and associativity of multiplication and thus is a non-sense. I am sorry but Calc was correct before you introduce the same bug as in Excel.
If we really need to compute n-root for n odd integer it would be better to define a function nroot(x,n) defined as x^(1/n) if x > 0 and -((-x)^(1/n)) if x < 0
If we really need to reproduce this MS-Excel bug, we should isolate it in some optional compatibility package, so that users who want do correct mathematics or do not import xlsx files are not affected by this bug.
Best regards. JBF
|