Simplify long product to avoid redundant computation

28 Views Asked by At

I have a product of the following form: $$p(\theta)=\Pi_{i=1}^N (1+b_i\cdot c(\theta)).$$

Now I will need to compute this product for different $\theta$. Without any simplification, each evaluation takes $O(N)$. The problem is that $N$ is quite large so I would like to simplify this expression so that the computation takes less than $O(N)$. Is it possible?

Edit: one can assume that any expression involves only $_$ can be computed once and stored and never needed to be computed again--so that will take no computing time. I'm just not sure how to collect terms.

1

There are 1 best solutions below

0
On

You can write $$p(\theta)=\sum_{i=0}^Na_ic^i(\theta)$$Here $a_0=1$, $a_1=\sum_{i=1}^Nb_i$, $a_2=\sum_{i=1}^{N-1}\sum_{j>i}^Nb_i,b_j$, $a_3=\sum_{i=1}^{N-2}\sum_{j>i}^{N-1}\sum_{k>j}^Nb_ib_jb_k$, and so on. You would still need to compute all $c^n(\theta)$. You can simplify this expression if $|c(\theta)|\gg 1$ or if $|c(\theta)|\ll 1$. In the first case, you can just ignore the $1$ in the product, and you are left with $$p(\theta)\approx c^N(\theta)\prod_{i=1}^Nb_i$$ In the second case, with small $c$, you can ignore the higher powers, so $$p(\theta)\approx 1+c(\theta)\sum_{i=1}^Nb_i$$