Re: Mathematical models for loop calculations
- From: "Paul E. Black" <p.black@xxxxxxx>
- Date: Wed, 26 Sep 2007 15:59:03 -0400
On Wednesday 26 September 2007 09:10, Tim Frink wrote:
I'm looking for an approach to represent calculations within
a loop (of a computer program) by mathematical models. To make
things clear, here is a simple example for a loop that iterates
10 times:
i = 0,
b = 2,
...
while( i < 10 ) {
a = a + 1;
b = b + b;
...
i++;
}
So you would want to come up with
a' = a + 10
b' = 2^11
where a' and b' are the values of "a" and "b" after the loop exits,
right?
(If you didn't know the beginning value of i, it is
a' = a + 10-i
b' = 2^(i+1)
instead.)
In the broadest case, the problem is unsolvable: you can't always
prove a loop ends (think Fermat's last theorem or halting problem);
even for the cases you can, you can't easily prove how many times it
will loop (think cascading numbers); even if you can, there may be no
simple way to express the result (think sum of randomoid numbers).
That said, there are lots of ways to get some results.
My first idea was to express the calculations by mathematical series
but I still don't know exactly how to do this.
Yes, solving a mathematical series is probably the best all-around
approach. Some arithmetic and geometric series have nice forms
you can use. There are classes to teach how to solve a series.
Powerful math packages, like Mathematica or Maple, are great at
solving a series.
Sincerely,
-paul-
Paul E. Black (p.black@xxxxxxx)
.
- References:
- Mathematical models for loop calculations
- From: Tim Frink
- Mathematical models for loop calculations
- Prev by Date: Re: Data structure behind Google Suggest
- Next by Date: Re: Mathematical models for loop calculations
- Previous by thread: Mathematical models for loop calculations
- Next by thread: Re: Mathematical models for loop calculations
- Index(es):
Relevant Pages
|