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:] += G[i]*F[:-i-1]

Basically, I multiply $F$ with $G[i]$, shift the result $i+1$ to the right and add it on $G$ at each iteration.

For example, let

$$ F=[0.5,0.2,0.2,0.2,0.1] $$

Then, $G$ will evolve as

$$ \begin{align} \text{Iter 0 } &\rightarrow G = [0.5,0.2,0.2,0.2,0.1]\\ \text{Iter 1 } &\rightarrow G= [0.5,0.45,0.3,0.3,0.2]\\ \text{Iter 2 } &\rightarrow G= [0.5,0.45,0.525,0.39,0.29]\\ \text{Iter 3 } &\rightarrow G= [0.5,0.45,0.525,0.6525,0.395]\\ \text{Iter 4 } &\rightarrow G= [0.5,0.45,0.525,0.6525,0.72125]\\ \end{align} $$ In the Iter 1, I multiply $G[0]=0.5$ with $[0.5,0.2,0.2,0.2]$ and add it to $G$ starting at the second element. In Iter 2, I multiply $G[1]=0.45$ with $[0.5,0.2,0.2]$ and add it to $G$ starting at the third element and so on.

When laid out, $G[i]$ expressed as $F[i]$ becomes $$ \begin{align} G[0] &= F[0]\\ G[1] &= F[1]+F^2[0]\\ G[2] &= F[2] + 2F[0]F[1]+F^3[0]\\ G[3] &= F[3] + 2F[0]F[2] + F^2[1] + F[1]F^2[0]+2F^2[0]F[1]+F^4[0] \end{align} $$

Each term can be expressed as convolution of $G$ upto that point with $F$ upto that point, i.e.,

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

However, $G$ as it is, is still a function of $F$.

I am only interested in the first $N$ elements of $G$. So, if $G$ becomes longer like we have in convolution, I can discard the elements after the $N^{th}$ element. Even after laying out each term, I could not discern any patterns except the convolution.

How can I express this mathematically? Is this some sort of convolution or transform?

Thanks in advance!

ck1987pd
  • 1,129
  • 1
    So G grows in length at each step? Can you give a concrete example? – Karl Jul 31 '23 at 06:19
  • 1
    @Karl I presented an example above. It should be clearer now. $G$ can grow in length but I am only interested in the first $N$ elements. I preserve the length by the indices in the code block. – ck1987pd Jul 31 '23 at 07:59

0 Answers0