Re: Math::Pari 'factor' is wrong
- From: gamo <gamo@xxxxxxxxxxxx>
- Date: Sat, 18 Mar 2006 11:58:53 +0100
On Sat, 18 Mar 2006, Ilya Zakharevich wrote:
[A complimentary Cc of this posting was sent to
gamo
<gamo@xxxxxxxxxxxx>], who wrote in article <Pine.LNX.4.64.0603171934330.23094@xxxxxx>:
for $i (0..1_000_000_000) {
$P = 5*$i**4-10*$i**3+20*$i*$i-15*$i+11;
This does not make sense. Why do approximate calculations, if you
want integer arithmetic?
That's not an approximate calculation. $P It's the value of the polynomial
in the point $i.
The correct way is (if $i fits exact Perl types)
for $j (0..1_000_000_000) {
my $i = PARI $j; # Or PARI "$j" to be absolutely sure
$P = ...
Ok, I'll revise that.
Thanks, all the best
Or make a while() loop operating on a Math::Pari integer, not Perl integer.
But anyway, I discovered a bug in unsigned --> PARI conversion.
Sigh...
perl -MMath::Pari -wle "print PARI 3936116531"
-358850765
This is clearly a bug, Perl data contains enough bits of info to
deduce the correct result... >>TODO
Hope this helps,
Ilya
--
http://www.telecable.es/personales/gamo/
Sólo hay 10 tipos de personas, las que saben binario y las que no
perl -e 'print 111_111_111**2,"\n";'
- Follow-Ups:
- Re: Math::Pari 'factor' is wrong
- From: Ilya Zakharevich
- Re: Math::Pari 'factor' is wrong
- References:
- Math::Pari 'factor' is wrong
- From: gamo
- Re: Math::Pari 'factor' is wrong
- From: Ilya Zakharevich
- Math::Pari 'factor' is wrong
- Prev by Date: Re: Math::Pari 'factor' is wrong
- Next by Date: Re: Math::Pari 'factor' is wrong
- Previous by thread: Re: Math::Pari 'factor' is wrong
- Next by thread: Re: Math::Pari 'factor' is wrong
- Index(es):