- #1
Hobold
- 83
- 1
Understading sum/product algorthms
Hello there,
I'm having a little trouble understanding sum/product algorithms. I can do single sum/product algorithms, but when it comes to multiple/combined summations or products I just can't follow.
Ex.:
[tex]\sum_{i=0}^n (a_i x + c_i)[/tex]
Ok, this one was pretty simple, I have no problem in doing that. Though when it comes to things like
[tex]\sum_{i=0}^n \left ( \prod_{j=0}^i (a_i x + c_i) \right )[/tex]
it gets hard. I have made a few algorithms, though I have no idea if they are right. I assume you can write using only one loop, but I have no idea how. Here's what I'd write for that one:
I can't work the other way around as well. When I notice some algorithm results in combined product/sum notation, I can't write it right, such as
Could anyone help me understand? Or at least suggest any book or text on these?
Hello there,
I'm having a little trouble understanding sum/product algorithms. I can do single sum/product algorithms, but when it comes to multiple/combined summations or products I just can't follow.
Ex.:
[tex]\sum_{i=0}^n (a_i x + c_i)[/tex]
Ok, this one was pretty simple, I have no problem in doing that. Though when it comes to things like
[tex]\sum_{i=0}^n \left ( \prod_{j=0}^i (a_i x + c_i) \right )[/tex]
it gets hard. I have made a few algorithms, though I have no idea if they are right. I assume you can write using only one loop, but I have no idea how. Here's what I'd write for that one:
Code:
z = 0; y = 1;
for i = 0 to n do
for j = 0 to i do
z = z + a[i] * x + c[i];
end for
y = y*z;
end for
I can't work the other way around as well. When I notice some algorithm results in combined product/sum notation, I can't write it right, such as
Code:
v = a[0];
z = x;
for i = 1 to n do
v = v +z*a[0];
z = x*z;
end for
Could anyone help me understand? Or at least suggest any book or text on these?