# Cannot do odd roots of negative numbers.

Bug #288446 reported by Richard Eames on 2008-10-24
Affects Status Importance Assigned to Milestone
Fix Released
Low
Low
Unassigned

### Bug Description

Binary package hint: gcalctool

It says something like (-4)^(1/7) is a "Math operation error". My TI-83 says otherwise. This almost cost me a homework assignment -_-.

## Related branches

 StatusWoe (brentsmithis) wrote on 2008-10-24: #1

This isn't a bug so much as what would likely be a significant enhancement request.
This would require the implementation of complex numbers in gcalctool.

A brief explaination:

fractional exponents are the same as exponentiated roots, (not sure if I have the terminology right there). for example "x to the 1/2" is the same as saying "the square root of x". This isn't a problem until we allow negative bases, which requires the roots of negative numbers and can often force the usage of complex numbers. There are certainly better explanations of this on the web, but in any case, this is beyond the scope of gcalctool since it doesn't allow complex numbers to the best of my knowledge.

 StatusWoe (brentsmithis) wrote on 2008-10-24: #2

Not a bug, this would require complex numbers which are outside the scope of gcalctool.

 Changed in gcalctool: status: New → Invalid
 Richard Eames (naddiseo) wrote on 2008-10-24: #3

It doesn't require imaginary numbers for odd roots, only even roots, is a bug. The cube root of a negative number is defined, as is the 5th root of a negative number, etc, so no need to implement complex numbers.

 StatusWoe (brentsmithis) wrote on 2008-10-24: #4

While you are correct in saying that the odd roots will give a single, non-complex answer I'm not sure how one would go about identifying the odd roots in a reasonable, consistent fashion.

I would assume that the bracketed exponent is evaluated initially to a decimal. For the most part you could invert the decimal and get the base of the fraction and using that determine if the root will be even or odd. However for irrational (currently the check is against non-integers so these are caught) and repeating fractions this number is only approximate, which, when used to evaluate the parity of root could introduce errors.

I think that dealing with non-integer exponents of negative bases is beyond the scope of gcalctool and more in line with something like Rascal, Genius, Qalculate, or even Octave. However, I understand that since this is the default shipping calculator with many Gnome desktops there may be a desire to see it's functionality increased.

 David Kolossa (dickhuuhn-deactivatedaccount) wrote on 2009-02-28: #5

This bug is rather severe in my opinion and I can confirm this behavior. In addition, this could be fixed rather easily if one would introduce an extra button/function to take the n-th root of a number and if the argument should be negative it just checks whether the root is odd or not.

That button was missing anyway since it exists on any scientific calculator. For these two reasons I am reopening the bug.

 Changed in gcalctool: status: Invalid → New
 Robert Ancell (robert-ancell) wrote on 2009-03-27: #6

Thank you for your bug report. This bug has been reported to the developers of the software. You can track it and make comments at:
http://bugzilla.gnome.org/show_bug.cgi?id=576973

 Changed in gcalctool: importance: Undecided → Low status: New → Triaged
 Changed in gcalctool: status: Unknown → Confirmed
 Robert Ancell (robert-ancell) wrote on 2009-05-11: #7

Fixed upstream

 Changed in gcalctool (Ubuntu): status: Triaged → Fix Committed
 Changed in gcalctool: status: Confirmed → Fix Released
 Launchpad Janitor (janitor) wrote on 2009-06-02: #8

This bug was fixed in the package gcalctool - 5.27.2-0ubuntu1

---------------
gcalctool (5.27.2-0ubuntu1) karmic; urgency=low

* New upstream release (LP: #380248)
- Add 1's and 2's complement to programming mode (Robin Sonefors, Bug #581253)
- Add variable word size for bitwise functions (Robin Sonefors, Bug #581253)
- Remove negative sign from numbers rounded to zero. This is only a partial
fix as the error value is still visible in scientific notation
(Robert Ancell, Bug #560802)
- Support odd roots of negative numbers (Robert Ancell, Bug #576973) (LP: #288446)
- Keep settings (show zeroes, thousands separator etc) when changing modes
(Robert Ancell, Bug #580398) (LP: #366904)
- Add a --solve command-line argument (Robert Ancell)
- Really fix the license text in the about dialog (Robert Ancell, Bug #579174) (LP: #359893)
- Made parser reentrant and part of MP code (Robert Ancell)
- Remove references to arithmetic/left-to-right precedence from the manual
(Robert Ancell, Bug #559734) (LP: #294903)
- Fix grammatical errors in manual (Bruce Cowan, Bug #569275)
- Remove untranslated figures in documentation - they are automatically
copied from the C documentation (Robert Ancell, Bug #566680)
- Updated translations: si (K.P.Gayan Tharaka)
* debian/patches/01_lpi.patch:
debian/patches/99_autoconf.patch: Refreshed

-- Robert Ancell <email address hidden> Thu, 28 May 2009 09:30:49 +0200

 Changed in gcalctool (Ubuntu): status: Fix Committed → Fix Released
 Changed in gcalctool: importance: Unknown → Low