How to calculate infinite series with NetLogo? For example, how to calculate the sum of x^i, where i is from 0 to 10? (the lower bound of summation is i=0 and the upper bound of summation is i=10 (or infinite), x is an indexed variable representing each successive term in the series)
You can't do infinite series, NetLogo doesn't have algebraic manipulation. However, you can construct a function that takes the relevant powers and adds them together.
I think this is what you want:
to-report sum-power [#x #upper]
let range-list range (#upper + 1)
let result reduce [ [so-far next] -> #x ^ next + so-far ] range-list
report result
end
For example, sum-power 2 3
returns 14 because the first is (0 + 2^1), then add 2^2, then 2^3 = 0 + 2 + 4 + 8