On 2008-12-11 14:48-0000 Andrew Ross wrote:

> This [example 02 issues] was merely a slight difference between examples. In 
> the perl
> version the 0-1 numbers were multiplied by 255, as opposed to 255.001 in
> the C version. Fix this and the results are identical. I've committed
> this to svn.

Thanks, Andrew, for spotting that.

> This [example 27 issues] looks like small rounding errors to me. Coordinates 
> are never
> out by more than 1.

You were correct it was a problem with the Perl math library.  The main
trouble I had in finding this was figuring out how to print out individual
elements of a pdl array.  For future reference, this worked:

for (my $i = 0; $i < int($windings)*int($steps)+1; $i++) {
       printf("%f,%f,%f,%f\n",  $phi->slice($i)->slice('(0)'), 
$phiw->slice($i)->slice('(0)'), $xcoord->slice($i)->slice('(0)'), 
$ycoord->slice($i)->slice('(0)'));
}

The result showed the errors gradually increased with phi which lead me to
the scale error in the PI value used in dphi.

Here is the crux of that scale error.
perldl> p 4*atan2(1,1)
3.14159265358979
perldl> p acos(-1.)
3.14159274101257

The first is the correct value of PI to the printed precision, the second
is wrong in the 7th place.  In contrast, the C math library (and every
other language binding we have) calculates PI to full precision
without problems for acos(-1.)

Doug, will you please do the honors and make the appropriate bug report?
This is ugly, and I am amazed such a perl math library error is still with
us after all these years.

I have just calculated PI using atan2 for the example (revision 9087) and
the results are now

perl
   Missing examples   :
   Differing examples :  23

So we are close to perfection.

I notice Doug has already uploaded a fix for example 23 so we may be
PDL-perfect shortly. However, it is taking a while to propagate version 0.46
of Doug's PDL Graphics, PLplot package at CPAN so I will have to wait to
make the final test.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to