You are not logged in.

- Topics: Active | Unanswered

Pages: **1**

**All_Is_Number****Member**- Registered: 2006-07-10
- Posts: 258

I realized recently that the mathematical equivalent of a For Next loop in programming is the finite series. I'm sure many on this forum already knew that, but I had never made the connection.

A simple example:

is the same as

10 y = 0

20 for x = 1 to 10

30 y = y + 1

40 next x

50 print y

60 end

(I've used BASIC as the program language, but many programming languages have For Next loops.)

Nested loops can also be represented by "nested" finite series. Each loop has its own sigma representation.

This is nothing groundbreaking, to be sure, but it is handy to know because sometimes one method is more convenient to use than the other.

*You can shear a sheep many times but skin him only once.*

Offline

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

yes. although you can have far more complicated strucrures in a program that would look rather silly in maths.

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

theres one thing that always bugged me, how can you use a sigma notation, when you dont want to go up in integer steps?

what if you wanted a summation from -2 to -4.89 in 0.01 intervals for e^x? would you just have to do something like

and carrying on from what you said.

you could think of a (dont know its name)

as being either a for loop in the format

float csum = 1;

for(int i = 0; i<=10; i++) csum *= exp(i);

or maybe as a recursive function

function prodex(float n = 1, int i = 0)

{

if(i<=10)

return prodex(n*exp(n),i+1);

else

return n;

}

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**All_Is_Number****Member**- Registered: 2006-07-10
- Posts: 258

luca-deltodesco wrote:

theres one thing that always bugged me, how can you use a sigma notation, when you dont want to go up in integer steps?

what if you wanted a summation from -2 to -4.89 in 0.01 intervals for e^x? would you just have to do something like

perhaps:

*You can shear a sheep many times but skin him only once.*

Offline

**Dross****Member**- Registered: 2006-08-24
- Posts: 325

You don't have to have a sumation in that format, you could use a capital sigma over a set, like:

Bad speling makes me [sic]

Offline

**krassi_holmz****Real Member**- Registered: 2005-12-02
- Posts: 1,906

Or you can define abstract operators, which act as programs:

Or you can use them as "constructors" for more complex objects:

*Last edited by krassi_holmz (2006-10-29 13:36:28)*

IPBLE: Increasing Performance By Lowering Expectations.

Offline

Pages: **1**