Re: Mathematical models for loop calculations



Tim Frink said:

On Wed, 26 Sep 2007 13:46:20 +0000, Richard Heathfield wrote:

Thank you. This showed me that this should work in general.

b = pow(2, I);

Seems to be a small mistake,
should be "b = power(2,I);

I fail to see the mistake. You've just typed what I typed, except that
you've written power rather than pow. The pow function is in the standard
C library, which is why I chose it. If your language provides power
instead of pow, that's fine, but it doesn't make my choice a mistake.

Could you think of any cases where this approach by expressing
the calculations by formulas will fail?

Yup. Non-linear dynamical systems spring to mind. For example, consider the
logistic mapping

k = 3.99;
x = 0.1;
for(i = 0; i < n; i++)
{
x = k * x * (1.0 - x);
}

The behaviour is chaotic (in the mathematical sense of the word). Good luck
finding an equation that exactly mimics n iterations of the loop, for any
reasonably large n. (If you manage it, publish!)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages