[Tfug] OT: Python: Fractional Exponents of Negative Numbers

David Cowell davidwcowell at cox.net
Mon Jan 18 22:24:43 MST 2010


My first jump would be using De Moivre's theorem and division (or
multiplication) of angles from the positive x-axis. Things like this I
work out on graph paper and then move on to a computer language later.
(But then I'm over 45 y.o.) The way I see it (unless I don't understand
the complexity of your request -- quite possible) it should just be a
few lines of prescient code.

==


At the risk of being flamed; I posted this on a python forum and thought I would solicit comments from TFUG since I know there are some great programmers here.

Because I get a ValueError:

"Is there a module out there that can approximate a real solution to a function containing a negative number raised to a fractional exponent? For example, solving for m in: C=m**m*((A**(m+1))/B**m), where A and B are known, and of opposite sign, and C is known.

My understanding is, an iteration is required, such as Newton's Method (that isn't reliable when using complex numbers), but perhaps with some arbitrary precision all fractional exponents containing even numbered denominators can be excluded, so as not to need to import cmath (which is buggy in IDLE), nor have solutions containing complex numbers, since it can be implied that the solution to m lies in fact between two arbitrarily close rational numbers, ie. fractions with odd-numbered denominators??"

Or: How do I do this???

Thanks,
Charles







More information about the tfug mailing list