Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ ¹ ² ³ °
 

You are not logged in. #1 20061030 00:13:34
Finite Series and For Next LoopsI 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. 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. #2 20061030 03:27:49
Re: Finite Series and For Next Loopsyes. 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. #3 20061030 03:46:25
Re: Finite Series and For Next Loopstheres one thing that always bugged me, how can you use a sigma notation, when you dont want to go up in integer steps? 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. #4 20061030 03:54:31
Re: Finite Series and For Next Loops
perhaps: You can shear a sheep many times but skin him only once. #5 20061030 04:50:23
Re: Finite Series and For Next LoopsYou 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] #6 20061030 12:31:48
Re: Finite Series and For Next LoopsOr 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 (20061030 12:36:28) IPBLE: Increasing Performance By Lowering Expectations. 