Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static double logSumExp(double a, double b) { double x = (a < b) ? a : b; double y = (a < b) ? b : a; if (y - x > 50) { return y; } else { return x + Math.log(1.0 + Math.exp(y - x)); } } }