function log_sum = logsum(x)

max_arg = max(x);
log_sum = log(sum(exp(x - max_arg))) + max_arg;
return;
