Approximating a function

96 Views Asked by At

I'm sorry if this question in not well formed...

I would like to perform a computation of the following function:

f() = -2*X1 -1*X2 +0*X3 + 1*X4 +2*X5

(The function can be of more variables, but is always finite and the coefficients are always of this form: -n..-3,-2,-1,0,1,2,3,..n ). Each Xi is also a sum other xi's, that is:

Xi = (xi1 +xi2 + ... xim).

I need some kind of approximation or something like that so I will be able to compute this efficiently, with limit set of operations, because n and m can be large numbers and I need to run this in MATLAB many times.

I can compute sums of the xi's and the Xi's very efficiently, (in O(1)), and I would like if possible to use this.

Suggestions for additional information and examples will be welcomed. Thanks.

1

There are 1 best solutions below

7
On

Your question can be resumed to the following form:

$$f(x_{i,j})=\sum^n_{i=1} a_{i} X_{i}=\sum^n_{i=1} a_{i} \sum^m_{j=1} x_{i,j}$$

with $a_i \in \Bbb Z$. For the largest coefficient $a_{i}^{max}$ you could define:

$$g(x_{i,j})=a_{i}^{max} \sum^n_{i=1} \sum^m_{j=1} x_{i,j}$$

$f$ would not exceed $g$. It should be to good extent efficient to calcualte $f\approx g$. I hope I understood your question correct.


possible optimization

$$g(x_{i,j})=g^{(p)}-|g^{(n)}|=p_{i}^{max} \sum^k_{i=1} \sum^l_{j=1} x_{i,j}-|n_{i}^{max}| \sum^k_{i=1} \sum^l_{j=1} y_{i,j}$$ while $p$ is for positive and $n$ for negative integers. Then approximate separately: $$f^{(p)}\approx g^{(p)}$$ $$f^{(n)}\approx |g^{(n)}|$$ So you may split your approximation to avoid cancellation in the series' approximation.