shifted with the logsumexp trick for stability

proof: