Understanding sum/product algorithms

  • Thread starter Thread starter Hobold
  • Start date Start date
  • Tags Tags
    Algorithms
Click For Summary

Discussion Overview

The discussion revolves around understanding sum and product algorithms, particularly focusing on the challenges of implementing combined summations and products in algorithmic form. Participants explore specific examples and seek clarification on notation and algorithm transformation.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant expresses difficulty in understanding combined sum/product algorithms, providing specific examples of notation and their corresponding algorithm attempts.
  • Another participant suggests initializing variables correctly for product and summation loops, emphasizing the need for proper initialization of z and y.
  • A different participant presents a simplified version of the algorithm, questioning the correctness of the inner product loop and its relation to the outer summation.
  • Further inquiry is made about transforming a specific algorithm into sum/product notation, referencing a text that lacks clarity on the topic.
  • One participant proposes manually calculating terms for the algorithm to understand the transformation process better, suggesting that the original author may have derived the notation from established techniques.

Areas of Agreement / Disagreement

Participants generally agree on the need for proper initialization in sum/product algorithms, but there is no consensus on the specific transformations and interpretations of the algorithms presented. The discussion remains unresolved regarding the clarity of the notation and the correctness of the proposed algorithms.

Contextual Notes

Limitations include potential misunderstandings of the algorithmic steps, dependencies on specific definitions of summation and product notation, and unresolved mathematical interpretations of the examples provided.

Hobold
Messages
82
Reaction score
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.:

\sum_{i=0}^n (a_i x + c_i)

Ok, this one was pretty simple, I have no problem in doing that. Though when it comes to things like

\sum_{i=0}^n \left ( \prod_{j=0}^i (a_i x + c_i) \right )

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?
 
Technology news on Phys.org


The inner loop is a product loop, you should initialize z = 1, and then each step should be z = z * ... or the alternate form z *= ... . The outer loop is a summation, so initialze y = 0, and each step should be y = y + ... or y += ...
 


Code:
sum:=0
for i:=0 to n do
	prod=1
	for j:=0 to i do
		prod:= prod * (a[i]*x + c[i])  // i?
	sum:= sum + prod
 


Thanks, I got that...

What would

Code:
v = a[0];
z = x;

for i = 1 to n do
   v = v +z*a[0];
   z = x*z;
end for

be in sum/product notation?

I am curretly using "Numerical Mathematics and Computing" by W. Cheney and D. Kincaid. Though it doesn't explain anything about those algorithms, there are some exercises in which the authors ask you to transform from notation -> algorithm and vice-versa. In the answer section, there are answers I cannot interpret such as:

Code:
z = b[n] + 1;

for k = 1 to n-2 do
   z = z*b[n-k] + 1;
end for

stands for z = 1 + \sum_{i=2}^n \prod_{j=2}^i b_j

I have really no idea on how the author got to that answer.
 


Hobold said:
I have really no idea on how the author got to that answer.
Try manually writing out the calculated terms for the first few loops, and you'll see why it works. As to how he figured it out, either he's clever or he copied the technique from yet another clever person.

z = b[n] + 1
z = (b[n] + 1) (b[n-1]) + 1 = b[n] b[n-1] + b[n-1] + 1
z = (b[n] b[n-1] + b[n-1] + 1) (b[n-2) + 1 = b[n] b[n-1] b[n-2] + b[n-1] b[n-2] + b[n-2] + 1
z = ...
 
Last edited:

Similar threads

  • · Replies 25 ·
Replies
25
Views
3K
Replies
9
Views
2K
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 30 ·
2
Replies
30
Views
7K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K