Re: Math::Pari 'factor' is wrong



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.


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

Thanks, all the best

--
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";'