Analyzing Recurrence Relations: Help with Summations Code

  • Thread starter EvLer
  • Start date
  • Tags
    Code
In summary, the conversation discusses a recurrence represented in terms of n and an analysis of a code using nested for loops. The speaker is unsure of how to switch to n and asks for help. The listener provides a solution involving summations and explains the steps taken. There is a typo in the solution, but the listener encourages the speaker to continue working on the problem independently.
  • #1
EvLer
458
0
Hi everyone,
I have the following recurrence to represent in terms of n:
Code:
  n-1    n      j
Sigma Sigma Sigma(c1) =...
 i =1  j = i+1 k=1
Basically, it is an analysis of following code:
Code:
for(i = 1 to n -1)
   for(j = i+1 to n)
       for(k = 1 to j)
      something of O(1)
So, I came up with summations but not sure how to switch to n.
So far I have following:
Code:
 n-1    n                    n-1    n            n-1      n       
Sigma Sigma (c1)(j-1) = c1 Sigma Sigma   j  - c1 Sigma Sigma 1;  
 i=1  j=i+1                 i=1   j=i+1          i=1   j=i+1
Second part resulted in c1[n(n-1) - [n(n+1)]/2 - (n-1)]; but I am stuck on the first part. Should I regard j = i + 1 as some constant?

Thanks a lot.
 
Last edited:
Physics news on Phys.org
  • #2
You shouldn't have "j - 1" you should just have j, i.e.

[tex]\sum _{i = 1} ^{n - 1}\sum _{j = i + 1} ^n \sum _{k = 1} ^j c_1 = \sum _{i = 1} ^{n - 1}\sum _{j = i + 1} ^n jc_1[/tex]

Now:

[tex]\sum _{i = 1} ^{n - 1}\sum _{j = i + 1} ^n jc_1 = \sum _{i = 1} ^{n - 1}\left (\sum _{j = 1} ^n jc_1 - \sum _{j = 1} ^i jc_1\right ) = c_1 \sum_{i = 1} ^{n - 1}\left (\frac{n(n + 1)}{2} - \frac{i(i - 1)}{2}\right )[/tex]

See if you can go from there.
 
  • #3
Thanks a lot for the reply.
I have some questions on your solution though:
how did you come up with i(i-1)/2 for the second expression in the parenthesis but n(n+1)/2 for the first? I know there is a minus before the i-expression but is it affecting the inner i-parenthesis?
From where you left off, I am thinking of breaking off the summation into two: one dependent on n and other dependent on i, is this the right direction?

Again, thank you very much.
 
  • #4
Sorry, that was just a typo. It should be n(n+1)/2, and i(i+1)/2. As for the rest, I'm sure you can figure out the right direction without me telling you.
 

1. What is a summation code and why is it important in scientific research?

A summation code is a mathematical expression used to represent the sum of a series of numbers. In scientific research, it is important because it allows for the efficient and accurate calculation of large sets of data, making it easier to analyze and draw conclusions from the data.

2. How do I write a summation code?

To write a summation code, you first need to determine the starting and ending values of the series of numbers you want to sum. Then, you can use the sigma notation (∑) to represent the sum, with the variable of summation (usually represented by i) and the starting and ending values written below and above the sigma symbol, respectively. Finally, you can write the mathematical expression for the series of numbers after the sigma symbol.

3. Can I use a summation code to solve any type of mathematical problem?

No, summation codes are specifically used to represent the sum of a series of numbers. They are not suitable for solving all types of mathematical problems, such as equations or inequalities.

4. What are some common mistakes to avoid when writing a summation code?

One common mistake is forgetting to include the starting and ending values in the notation. Another mistake is using the wrong variable of summation or not clearly defining the variable. It is also important to be consistent with the mathematical expression after the sigma symbol, as using different expressions can lead to incorrect results.

5. Are there any online resources available to help with writing summation codes?

Yes, there are many online resources available that provide tutorials, practice problems, and step-by-step guides for writing summation codes. Some popular resources include Khan Academy, Math is Fun, and Wolfram MathWorld.

Similar threads

  • Introductory Physics Homework Help
Replies
1
Views
901
  • Introductory Physics Homework Help
Replies
9
Views
1K
  • Introductory Physics Homework Help
Replies
7
Views
837
Replies
1
Views
544
  • Math Proof Training and Practice
Replies
8
Views
1K
  • Introductory Physics Homework Help
Replies
7
Views
3K
Replies
6
Views
1K
Replies
5
Views
2K
  • Mechanical Engineering
Replies
9
Views
1K
  • Introductory Physics Homework Help
Replies
4
Views
714
Back
Top