# Transform/approximate this expression to avoid undefined value

I have an expression like this

$$\sum_i^n\log\frac{x_i}{y_i}+\alpha\sum_i^nx_i\log\frac{x_i}{\beta}$$

A potential problem is that $x_i$ and $y_i$ may take value $0$ for certain $i$, hence making $\displaystyle\log\frac{x_i}{y_i}$ and $\displaystyle\log\frac{x_i}{\beta}$ undefined.

I wonder if there is any way of transform the expression to avoid this such that the resulting expression may only deviate from the original for an arbitrarily small amount.

-
It is the usual convention that $\log 0=-\infty, \log(a/0)=+\infty$, and $0.(\pm \infty)=0$ –  Ashok Jan 5 '12 at 5:55
@Ashok, resulting $-\infty$ or $+\infty$ from the expression above is meaningless in my case, so I would like to avoid them as well. –  Mark Jan 6 '12 at 17:20

Can you not simply define the series to be valid only when the ratios $\frac{x_i}{y_i}$ and $\frac{x_i}{β}$ are $>0$? that would solve the whole thing. Another, more involved way would be to form an 'analytic continuation' of the expression given by you, but that of course depends on a lot of things which you have not specified.
I can't justify for not allowing $x_i$ or $y_i$ to take value $0$ in the context of the problem. Are you suggesting to simply declare the whole expression invalid whenever $x_i$ or $y_i$ equals $0$? Could you please elaborate a bit more on this "analytic continuation" form of my expression? Many thanks. –  Mark Jan 6 '12 at 17:17
One way to transform the first sum is to start by writing $\log\prod_{i}^n\frac{x_i}{y_i}$. Now on first view this seems no help because if some $x_i$ or $y_i$ goes to $0$, you still get an invalid expression. However one thing one immediately notices is that if only some $x_i$ or only some $y_i$ goes to $0$, then you're out of luck; there's no way to rewrite the expression so that this will get defined. However if it is guaranteed that whenever some $x_i$ goes to $0$ also some $y_j$ goes to $0$ (where not necessarily $j=i$, that's the advantage of the product form), there may be hope: In that case, you might be able to reformulate the quantities as $x_i = a_{\sigma(i)} \xi_i$ and $y_i = a_{\sigma'(i)} \eta_i$ (with the same a for both, and where $\sigma$ and $\sigma'$ are permutations), so that neither $\xi_i$ nor $\eta_i$ can get $0$ (that is, all zeroes are "captured" by the $a_k$). In that case you can cancel $\prod_k^n a_k$ and simply replace all $x_i$ and $y_i$ by $\xi_i$ and $\eta_i$ (you are then free to use the sum form again if you prefer it). Of course whether that is possible depends on the details of your problem.
For the second sum, resolving the problem is easier: Rewrite $x_i\log\frac{x_i}{\beta}$ as $\log\left(\frac{x_i}{\beta}\right)^{x_i}$ and use the usual convention $0^0=1$. Alternatively you can simply define that in your function $0\log 0=0$.