473,320 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

mpmath puzzle

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
1 1258
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Developwebsites | last post by:
Hi all, I've made a sliding puzzle game in shockwave which works just fine, except I dont know how to have it solve itself. the URL is: http://members.aol.com/rglukov/games/selfsolve.htm ...
1
by: xavier vazquez | last post by:
I have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of...
0
by: xavier vazquez | last post by:
have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of the...
5
by: ashish0799 | last post by:
HI I M ASHISH I WANT ALGORYTHMUS OF THIS PROBLEM Jigsaw puzzles. You would have solved many in your childhood and many people still like it in their old ages also. Now what you have got to do...
3
by: oncue01 | last post by:
Word Puzzle Task You are going to search M words in an N × N puzzle. The words may have been placed in one of the four directions as from (i) left to right (E), (ii) right to left (W), (iii) up...
6
by: Phoe6 | last post by:
Hi All, I would like to request a code and design review of one of my program. n-puzzle.py http://sarovar.org/snippet/detail.php?type=snippet&id=83 Its a N-puzzle problem solver ( Wikipedia page...
2
by: Gio | last post by:
I'm getting K&R (it's on the way), should I also get the Answer Book? And while I'm there, should I get the Puzzle Book? Or should I save the Puzzle Book for when I'm more advanced? - Gio ...
4
by: honey777 | last post by:
Problem: 15 Puzzle This is a common puzzle with a 4x4 playing space with 15 tiles, numbered 1 through 15. One "spot" is always left blank. Here is an example of the puzzle: The goal is to...
5
by: dmf1207 | last post by:
Hi All! I'm new to javascript and need a little help with a simple puzzle im trying to design. I have a 600x100 pixel picture that I have sliced into 6 100x100 rectangles making a table of of 6...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.