[Tutor] Little problem with math module

Dick Moores rdm at rcblue.com
Mon Apr 21 17:17:15 CEST 2008

At 07:40 PM 4/20/2008, John Fouhy wrote:
>If you're going to be working with complex numbers, you might be
>better off looking at scipy or some other module that provides more
>mathematical grunt.

Try mpMath (<http://code.google.com/p/mpmath/>)

With version 0.7:

 >>> from mpmath import power, mpf
 >>> print power(-20,(1.0/3.0))
(1.35720880829745 + 2.3507546124512j)

Or, to a precision of, say, 43:

 >>> mp.dps = 43
 >>> print power(-20,(1.0/3.0))
(1.357208808297453347178047801626363199806658 + 

Dick Moores

UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/ 

More information about the Tutor mailing list