Re: How to express logarithm function by a pre-calculated table and a binary variable



Mengxiao Wu wrote:
My objective function includes logarithm part. log(x+1). I want to use
a pre-calculated table and a binary variable y to replace it. That
means the table is z --> log(z+1). If (x=z) then (y=1), else (y=0). I
do not know how to use inequal equations to express "If (x=z) then
(y=1), else (y=0)."
Who can help me? Thanks a lot!!!!

Well if x and z are floating point (real) numbers then you *do not*
want to compare them using .EQ. (OR ==).

Let eps be a real constant set to some small tolerance.

if abs(z-x)<eps then
y=1
else
y=0
end if


You may wish to express this as an indicator function which returns 0
or 1.

* Yes there are other fancy ways to do this but they remind me of "C".
*

-- Elliot

.