Just another Perl shrine | |
PerlMonks |
Re: incrementation loop fails?by stankuli (Initiate) |
on Sep 30, 2011 at 21:54 UTC ( [id://928935]=note: print w/replies, xml ) | Need Help?? |
the problem i reported was this loop executed correctly for about 40 iterations then it incremented $POWER incorrectly on the 41st iterations, then continues on correctly for at least 20 more iterations, but with the incorrect value after 41.
someone called kennethk suggested this kludge which corrected the problem.
apparently, perl is intended to allow for variable incrementation within loops as i had originally written it. it works for the first 40 iterations, and only fails on the 41st time through. that function call &HARMONIC_SERIES is rather putting some effort on the cpu, it doing the zeta exponential calculations about 10 million times, but the bug shows even at 1 million or 100 thousand series depths. so, i suspect that there must be some sort of memory overrun in the hardware causing the simplest iteration of the variable. there is nothing wrong with kludges when they are necessary. this one seems to allocate the variable to count each iteration outside of the loop, then reallocates $POWER variable after each iteration, so starts off with fresh contents recalculated with the increments. the dirichlet zeta calculations are an exercise in pure mathematics, and the lengthy decimal outputs are known as the open representation of the irrational convergence on to the limits being approximated by millions of incremental calculations. these are the correct results which match published values in books on this subject.
my thanks for your assistance in getting this part of the program to operate as it needs to. i may be back as the next part of the program does the riemann zeta calculations using complex numbers to find the nontrivial zeros in the function output.
In Section
Seekers of Perl Wisdom
|
|