real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
↓
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((exp(b) <= 0.98d0) .or. (.not. (exp(b) <= 1.0d0))) then
tmp = 1.0d0 / (exp(b) + 1.0d0)
else
tmp = exp(a) / (exp(a) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
↓
public static double code(double a, double b) {
double tmp;
if ((Math.exp(b) <= 0.98) || !(Math.exp(b) <= 1.0)) {
tmp = 1.0 / (Math.exp(b) + 1.0);
} else {
tmp = Math.exp(a) / (Math.exp(a) + 1.0);
}
return tmp;
}
herbie shell --seed 2023122
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:herbie-target
(/ 1.0 (+ 1.0 (exp (- b a))))
(/ (exp a) (+ (exp a) (exp b))))