Python Forum
Negative numbers and fractional powers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Negative numbers and fractional powers
#1
Python doesn't like it when I ask it things like, (-6)**(1/3). I can at least get some answer by changing it to (-6+0j)**(1/3), and it gives me a complex answer, but that's not quite complete, because in the complex plane, numbers have three cube roots. I can get multiple roots usingĀ [mpmath.root(a,b,k) for k in range(b)] (returning a**(1/b)), but that only works for whole-number roots, rather than arbitrary real exponents.

Is there a function out there somewhere that can give me every solution to an arbitrary a**b? I already use Sympy, so it would be great if it could work symbolically to give exact answers.
Reply
#2
possibly Sage?
http://www.sagemath.org/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  cmath.rect accepts a negative modulus JMB 2 303 Jan-17-2024, 08:00 PM
Last Post: JMB
  How to do bar graph with positive and negative values different colors? Mark17 1 5,000 Jun-10-2022, 07:38 PM
Last Post: Mark17
  is there any tool to convert negative base to int? Skaperen 7 2,330 May-27-2022, 07:30 AM
Last Post: Gribouillis
  Def code does not work for negative integers. doug2019 1 1,873 Oct-31-2019, 11:00 PM
Last Post: ichabod801
  offset can not be negative in File.seek()? jollydragon 6 6,866 Sep-28-2019, 03:08 AM
Last Post: jollydragon
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,661 May-09-2019, 12:19 PM
Last Post: Pleiades
  comparing fractional parts of floats Skaperen 4 3,266 Mar-19-2019, 03:19 AM
Last Post: casevh
  Positive to negative bernardoB 6 4,277 Mar-13-2019, 07:39 PM
Last Post: bernardoB
  Python regex with negative set of characters multiline sonicblind 2 3,352 Jul-30-2018, 08:43 PM
Last Post: sonicblind
  negative to positive slices Skaperen 3 3,590 Jan-29-2018, 05:47 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020