Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a programmer (not a mathematicians), and I am encountering a problem in my software which, if possibly solved mathematically would save a lot of performance issues.

I have an array of arrays (A):


the notation [x,y] is exactly the kind of notation used by the system I am working on.

Besides I have another array (B) containing the same 'kind of ordered' objects but disposed at root level:

[0,0] formerly [0,0] 
[0,1] formerly [1,0]
[0,2] formerly [1,1]
[0,3] formerly [2,0]
[0,4] formerly [3,0]
[0,5] formerly [3,1]

The problem I am facing is, given the A array index, how can I retrieve the index of the same element in B ? Which is, if my hypothetical function f(x,y) is accepting [2,0]

A-index = [2,0]

I would like to have in return

B-index = [0,3]

The instruments I have at hand are a function f(x) that return objects count in A at specific index, say:

f(2)=1 object count
f(3)=3 objects count

I also know the total number of object, in A and B which are the same.

I am posting here also because some suggested to use an integral, but honestly, I am a bit lost, and I do not have any instruments to verify this possible suggested solution.

Please feel free to correct the question in its syntax (especially the subject), or help me to rephrase in a more scientific way, and if you think this it's not a mathematical question, you can delete it anytime.

I did tried to search in forum, but due to my lack of knowledge I didn't manage to recognize a post with same problem.

share|cite|improve this question
up vote 0 down vote accepted

Let $F$ denote the result of summing up $f$, i.e.

$$ F(n)=\sum_{k=0}^{n-1}f(k)\;. $$

Then the B-index for A-index $[i,j]$ is $[0,F(i)+j]$.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.