By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

mpmath puzzle

P: n/a
For 1234 ** 10.9, why the wrong result from mpmath.power()?

========================================
#!/usr/bin/env python
#coding=utf-8
from mpmath import *

mpf.dps = 32

x = mpf(1234)
y = mpf(10.9)

print power(x,y)
print "4.9583278648155041477415234438717e+33" # from Windows calculator

"""
output:
4.9583278648155166864966558721921e+33
4.9583278648155041477415234438717e+33
"""
========================================
(Code is also at <http://python.pastebin.com/m72a277b8>)

Thanks,

Dick Moores

Nov 14 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Nov 13, 11:55 pm, Dick Moores <r...@rcblue.comwrote:
For 1234 ** 10.9, why the wrong result from mpmath.power()?

========================================
#!/usr/bin/env python
#coding=utf-8
from mpmath import *

mpf.dps = 32

x = mpf(1234)
y = mpf(10.9)

print power(x,y)
print "4.9583278648155041477415234438717e+33" # from Windows calculator

"""
output:
4.9583278648155166864966558721921e+33
4.9583278648155041477415234438717e+33
"""
========================================
(Code is also at <http://python.pastebin.com/m72a277b8>)

Thanks,

Dick Moores
Check this out, better than Windows or mpmath:
>>import gmpy
a = 1234
b = gmpy.f2q(10.9)
print b
109/10
>>c = a**b.numer()
d = gmpy.root(c,b.denom())
d
(mpz(4958327864815504147741523443871702L), 0)

Nov 14 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.