Closed GoogleCodeExporter closed 9 years ago
Your inputs only have double precision (where 0 and 0.5 happen to be exact).
You need to convert decimal literals to full-precision numbers with mpf:
>>> print ellipk(mpf('0.09'))
1.608048619930512801267207222238687157112176728802652558496349254
Or implicitly:
>>> print ellipk('0.09')
1.608048619930512801267207222238687157112176728802652558496349254
Original comment by fredrik....@gmail.com
on 26 Oct 2010 at 10:05
oh thank you; my code was (multiple lines in this comment form only!):
<---snip--->
for my_epsi in epsi:
epsi_sq=my_epsi*my_epsi
my_str = str(my_epsi) + ';x'+ str(ellipk(epsi_sq)) + ';x' +
str(pi/2*hyp2f1(0.5,0.5,1.0,epsi_sq)) + '\n'
<---snip--->
I changed that to :
<---snip--->
for my_epsi in epsi:
mpf_epsi_sq=mpf(my_epsi)*mpf(my_epsi)
my_str = str(my_epsi) + ';x'+ str(ellipk(mpf_epsi_sq)) + ';x' +
str(pi/mpf(2.0)*hyp2f1(mpf(0.5),mpf(0.5),mpf(1.0),mpf_epsi_sq)) + '\n'
<---snip--->
and that did not help!? I then realised that mpf() only works on strings... so
after I changed the definiton of the list epsi from
epsi=[0,0.00001,0.00002,0.00005,...,0.99999]
to
epsi=['0.0','0.00001','0.00002','0.00005',...,'0.99999']
all is fine now... newbie error... sorry... but it might be a good idea to
mention this behaviour of mpf() a bit ealier than in the penultimate paragraph
of the manual page...
Regards
Original comment by dr...@web.de
on 26 Oct 2010 at 3:11
No worry :)
I think the documentation is adequate. People will run into this "bug" no
matter what the documentation says. It's just something you have to live with
in the Python language (or C, or most other programming languages).
Original comment by fredrik....@gmail.com
on 30 Oct 2010 at 9:52
Original issue reported on code.google.com by
dr...@web.de
on 26 Oct 2010 at 9:38