I need to evaluate the following numerically:
$$ f = \frac{\exp(a)}{\exp(a)+\exp(b)+\exp(c) + \exp(d)} $$
$a,b,c$ and $d$ are large negative numbers, they are smaller than -1000. Numerically exp(-1000) is equal to zero. Directly evaluating this expression would thus lead to a numerator and a denominator equal to zero.
How can I evaluate this expression?
As @d.k.o.'s comment hints at, your expression is: $$ \frac{1}{1 + \exp(b - a) + exp(c - a) + \exp(d - a)} $$ If the resulting $b - a$, $c - a$, $d - a$ are still (very) negative (small exponentials), a few terms of the geometric series should be accurate enough. If some turn out positive, call them $A$, $B$, $C$ in order of decreasing value: $$ \frac{1}{1 + \exp(A) + \exp(B) + \exp(C)} = \frac{1}{\exp(A) (1 + \exp(B - A) + \exp(C - A) + \exp(-A))} $$ and this should work out better numerically.