Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
Multiple Summations of Integers with Dependent Indices

Subject: Multiple Summations of Integers with Dependent Indices

From: Michael

Date: 6 Oct, 2013 13:51:09

Message: 1 of 1

I am trying to write a function with two positive integer inputs (N and Z), so it would be f_Z(N). The function would have Z-1 summations with the maximum value being N-Z+1. The below should clarify. In the below, I use 'summa' as a linear form of sigma notation, where the the first argument is what is being summed, the second is the index to sum over, the third is the minimum value for the index and the last is the maximum. For example, summa(a^2,a,1,5) = 1^2+2^2+3^3+4^2+5^2=55.
f_1(N) = N
f_2(N) = 1+2+...+N = summa(a,a,1,N-1)
f_3(N) = summa(summa(a,a,1,b),b,1,N-2)
f_4(N) = summa(summa(summa(a,a,1,b),b,1,c),c,1,N-3)
With some numbers to help:
f_4(8) = [(5+4+3+2+1)+(4+3+2+1)+(3+2+1)+(2+1)+(1)] + [(4+3+2+1)+(3+2+1)+(2+1)+(1)] + [(3+2+1)+(2+1)+(1)] + [(2+1)+(1)] + [(1)]

I hope this examples the function. I have tried to expand this and find a linear representation and tried recursive, but can't seem to get a good algorithm. The difficult arises in that the maximum index of one summation depends on the value of index outside of it. I tried looking online, but couldn't find examples with this type of index dependence.

Thank you for your help.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us