1

Let $F[n]$ and $G[n]$ be arrays of length $N$. At first, $G=F$.

After initialisation, $G$ is calculated by the relation

for i in range(N-1):
    G[i+1:] += A*G[i]*F[:-i-1],

where $A$ is an real number satisfying $A<1$.

We can also express this as a convolution, i.e.,

$$ G[i+1] = F[i+1] + A\sum_{j=0}^i F[j]G[i-j]. $$

We have also established that the above operation is an integro-differential equation for continous time domain.

I provided an example for this operation here for $A=1$. Doing this operation brute force is $\mathcal{O}(N^2)$. This not feasible for a large array. For example, for $N=800000000$, it takes approximately 50 hours. It is also not possible to parallel process this operation, at least the brute force version of it.

Partially influenced by the matrix method for finding the fibonacci numbers as outlined here, if I can turn this into some sort of matrix multiplication, I can use singular value decomposition or something similar to speed up the process, although I am pretty sure singular value decomposition will not speed the process a lot for $N=800000000$.

The issue is that $G$ completely depends on $F$, however the dependence may not be linear.

I am looking for a fast method to implement the above operation. If possible, I would be happier if I could obtain $G[n]$ without explicitly computing $G[i]$ for $i<n$.

Thanks in advance!

PS: I was not sure whether to post this on stackoverflow or here, but I decided to try my luck here first.

ck1987pd
  • 1,129
  • 1
    Convolutions can be computed efficiently using FFTs, but I haven't figured out how to apply that here, as each convolution is on vectors of a different length. – D.W. Aug 31 '23 at 18:40
  • As this is being asked in a Math forum, could you please put a little more effort in stating this in mathematical language, or a least in an algorithmic language where you are not taking advantage of special semantics of a particular language that your audience may not be familiar with. Note that in addition to Range(N-1), [i:], [:i], += this also includes the fact that saying $x = x+1$ is just making a false statement in mathematical language. It is not an instruction to change the value of $x$. – Paul Sinclair Sep 01 '23 at 21:26
  • @PaulSinclair I already presented the discrete convolution version of the same operation. It does not include any code. The linked question even has a sample about how that operation works. – ck1987pd Sep 02 '23 at 12:38
  • That equation does not include any mention of $A$, violates the interpretation of $=$ that I took pains to point out in my comment, and is unclear as to which values of $G$ are used on the RHS, the originals, or the arleady modified. Stop making excuses, – Paul Sinclair Sep 02 '23 at 12:43
  • @PaulSinclair Sorry about that. Now it has A. Which values of $G$ should be obvious. It does not modify $G[n]$ for $n \leq i$. It finds the final result for $G[i+1]$ not a developing one. That value is later used to calculate $G[i+2]$. I even had a whole working example on the linked question so if you still don't understand, it is not because of the question – ck1987pd Sep 02 '23 at 17:40

0 Answers0